When you go to the Node download page, you will see the following instructions under the Package Manager tab:
Install nvm (Node Version Manager)
curl -o- https://raw.githubusercontent.com/nvm-sh/nvm/v0.40.1/install.sh | bash
Download and install Node.js (you may need to restart the terminal first)
nvm install 22
Verify the right Node.js version is in the environment
node -v
(should printv22.12.0
)Verify the right npm version is in the environment
npm -v
(should print10.9.0
)
This seems pretty straightforward. So let's start with step one. Open a terminal and enter the following command to install nvm (Node Version Manager):
curl -o- https://raw.githubusercontent.com/nvm-sh/nvm/v0.40.1/install.sh | bash
Fair warning - you may hit a snag when you get to the second step listed above. Go ahead and try it though, run: nvm install 22
. If you receive this message: zsh: command not found: nvm
, you need to do a couple of things before you can continue.
First, you need to make sure your bash profile is set up. Check to see if you have a bash profile. In the terminal, enter the following:
open ~/.bash_profile
If you do not have a bash profile, follow these steps:
- Navigate to your home directory
cd ~/
. - Create the file
touch .bash_profile
. - Now you can use
open ~/.bash_profile
to edit your bash profile. (You do not need to edit it at this time, so you can close the window that has opened.)
Now you need to load nvm and nvm bash_completion. Copy and paste the following into the terminal:
export NVM_DIR="$HOME/.nvm"
[ -s "$NVM_DIR/nvm.sh" ] && \. "$NVM_DIR/nvm.sh"
[ -s "$NVM_DIR/bash_completion" ] && \. "$NVM_DIR/bash_completion"
Try running nvm install 22
again. This time you should see the following in the terminal:
Downloading and installing node v22.12.0...
Downloading https://nodejs.org/dist/v22.12.0/node-v22.12.0-darwin-arm64.tar.xz...
######################################################################### 100.0%
Computing checksum with shasum -a 256
Checksums matched!
Now using node v22.12.0 (npm v10.9.0)
Creating default alias: default -> 22 (-> v22.12.0)
This is what success looks like! (In this situation, anyway 😅)
You should be able to follow the last two steps for installing Node now.
Enter node -v
first. Then enter npm -v
. These final steps aren't absolutely required, but they will verify which version of Node and npm you are now using. Running node -v
should print v22.12.0
(which is what was indicated in the message that loaded when we ran nvm install 22
). Running npm -v
should print 10.9.0
, which was also in that message.
Now you can create and run Node applications, install packages and libraries, and more!
Top comments (0)