DEV Community

Pradeep Kumar
Pradeep Kumar

Posted on Edited on

Install Node on MacOS M1/M2/Apple Silicon

1. Create ~/.zshrc if not exist, using following command

touch ~/.zshrc
Enter fullscreen mode Exit fullscreen mode

2. Download NVM

Get the latest version URL from:
https://github.com/nvm-sh/nvm

curl -o- https://raw.githubusercontent.com/nvm-sh/nvm/v0.39.5/install.sh | bash
Enter fullscreen mode Exit fullscreen mode

3. Update .zshrc

Run

export NVM_DIR="$HOME/.nvm"
Enter fullscreen mode Exit fullscreen mode

OR

Open .zshrc: nano .zshrc and add the following line:

export NVM_DIR=~/.nvm
Enter fullscreen mode Exit fullscreen mode

Save and run:

source .zshrc
Enter fullscreen mode Exit fullscreen mode

Close the terminal and open it again.

3. Install Node

nvm install --lts
Enter fullscreen mode Exit fullscreen mode

Try running following command to verify versions:

node -v
npm -v
Enter fullscreen mode Exit fullscreen mode

Other useful commands

To check all available node version

nvm ls
OR
nvm ls-remote
Enter fullscreen mode Exit fullscreen mode

To install specific version

nvm install <version>
Enter fullscreen mode Exit fullscreen mode

eg:

nvm install v16.19.0
Enter fullscreen mode Exit fullscreen mode

Switch to specific version

nvm use <version>
Enter fullscreen mode Exit fullscreen mode

Set default node version

nvm alias default <version>
Enter fullscreen mode Exit fullscreen mode

Top comments (5)

Collapse
 
ramospedro1421 profile image
Pedro Ramos •

Thank you! That helped me a lot!!

Collapse
 
sergnotes profile image
Serg.io •

Thank you! I was running into permission issues earlier, so I had to do a complete re-install using your instructions.

Collapse
 
sergeylitvin profile image
Litvin Sergey •

Thanks! It's working for me.

Collapse
 
zayynahmedd profile image
Zain Ahmed •

Hey tysm. I am a total noob and this worked for me v easily. I initially was trying the Homebrew method on my Mac M2 but kept failing and didn't know why.

Collapse
 
blueorris profile image
blueorris •

Thanks! But for the step of adding path to the environment, I followed the official GitHub (which is shown at the top of this blog). That works for me.