how do i install node js on mac
- User
how do i install node js on mac
- Assistant
To install Node.js on a Mac, you have several options. Here are the most common and straightforward methods:
Method 1: Using the Official Node.js Installer
-
Download Installer
- Go to the official Node.js website: https://nodejs.org/
- You will see two versions:
- LTS (Long Term Support): Recommended for most users.
- Current: Latest features but may be less stable.
- Download the macOS installer (
.pkgfile) for your preferred version.
-
Run the Installer
- Open the downloaded
.pkgfile. - Follow the prompts to complete the installation.
- Open the downloaded
-
Verify installation
- Open Terminal.
- Check Node.js version:
node -v - Check npm (Node Package Manager) version:
npm -v
Method 2: Using Homebrew
If you use Homebrew (a popular macOS package manager), installation can be very simple.
-
Install Homebrew (if you don't have it already)
/bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)"Follow any on-screen instructions.
-
Install Node.js via Homebrew
brew install node -
Verify installation
node -v npm -v
Method 3: Using Node Version Manager (nvm)
nvmallows you to install and manage multiple Node.js versions.-
Install nvm
curl -o- https://raw.githubusercontent.com/nvm-sh/nvm/v0.39.4/install.sh | bashThen, either restart your terminal or run:
source ~/.zshrc(or
source ~/.bashrcorsource ~/.profiledepending on your shell) -
Install the latest Node.js
nvm install nodeOr install a specific version:
nvm install 18 -
Use a specific Node.js version (optional)
nvm use 18 -
Verify installation
node -v npm -v
Summary:
- For beginners or quick setup, the official installer or Homebrew is easiest.
- For managing multiple versions, use nvm.
If you want, I can guide you through any of these methods step-by-step!
-