1. Create ~/.zshrc
if not exist, using following command
touch ~/.zshrc
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
3. Update .zshrc
Run
export NVM_DIR="$HOME/.nvm"
OR
Open .zshrc: nano .zshrc
and add the following line:
export NVM_DIR=~/.nvm
Save and run:
source .zshrc
Close the terminal and open it again.
3. Install Node
nvm install --lts
Try running following command to verify versions:
node -v
npm -v
Other useful commands
To check all available node version
nvm ls
OR
nvm ls-remote
To install specific version
nvm install <version>
eg:
nvm install v16.19.0
Switch to specific version
nvm use <version>
Set default node version
nvm alias default <version>
Top comments (5)
Thanks! It's working for me.
Thank you! That helped me a lot!!
Thank you! I was running into permission issues earlier, so I had to do a complete re-install using your instructions.
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.
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.