DEV Community

Cover image for How to install and Configure NVM on Mac OS
Ajeet Singh Raina
Ajeet Singh Raina

Posted on • Updated on • Originally published at collabnix.com

How to install and Configure NVM on Mac OS

Follow me on Twitter

nvm (Node Version Manager) is a tool that allows you to install and manage multiple versions of Node.js on your Mac. To install nvm on a Mac, you will need to follow these steps:

Install Homebrew

nvm is not available in the default package manager for Mac, so you will need to install Homebrew first. To do this, open a terminal window and run the following command:

/bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install.sh)"
Enter fullscreen mode Exit fullscreen mode

Install nvm

Once you have Homebrew installed, you can use it to install nvm by running the following command:

brew install nvm
Enter fullscreen mode Exit fullscreen mode

Add nvm to your shell profile: To make nvm available every time you open a new terminal window, you will need to add the following line to your shell profile (e.g., ~/.bash_profile or ~/.zshrc):

source $(brew --prefix nvm)/nvm.sh
Enter fullscreen mode Exit fullscreen mode

Install Node.js

Once nvm is installed, you can use it to install the latest version of Node.js by running the following command:

nvm install node
Enter fullscreen mode Exit fullscreen mode

How to use specific version of NodeJS

To use a specific version of Node.js with nvm, you will need to follow these steps:

List available Node.js versions

To see a list of all available Node.js versions that you can install with nvm, run the following command:

nvm ls-remote
Enter fullscreen mode Exit fullscreen mode

Install the desired version

To install a specific version of Node.js, such as version 16, use the following command:

nvm install 16
Enter fullscreen mode Exit fullscreen mode

Use the installed version

Once the desired version of Node.js is installed, you can use it by running the following command:

nvm use 16
Enter fullscreen mode Exit fullscreen mode

Set the default version: If you want to use a specific version of Node.js by default, you can set it as the default version using the following command:

nvm alias default 16
Enter fullscreen mode Exit fullscreen mode

Further Readings:

Top comments (9)

Collapse
 
tchiinhemba profile image
Eládio Tchiinhemba

You probably ran into this problem: zsh: command not found: node
just add the following code to the file: .zshrc

You probably ran into this problem: zsh: command not found: node

just add the following code to the file: .zshrc

export NVM_DIR="$([ -z "${XDG_CONFIG_HOME-}" ] && printf %s "${HOME}/.nvm" || printf %s "${XDG_CONFIG_HOME}/nvm")"
[ -s "$NVM_DIR/nvm.sh" ] && . "$NVM_DIR/nvm.sh" # This loads nvm

Collapse
 
ajeetraina profile image
Ajeet Singh Raina

Thanks for the comments. I'm sure it will help others.

Collapse
 
tchiinhemba profile image
Eládio Tchiinhemba

Amazing...

Collapse
 
ajeetraina profile image
Ajeet Singh Raina

Glad that you found it useful.

Collapse
 
ajeetraina profile image
Ajeet Singh Raina

Thanks for your feedback.

Collapse
 
leonid_frontend profile image
Leonid Yakovlev

Thank you!

Collapse
 
ajeetraina profile image
Ajeet Singh Raina

Glad that you liked it.

Collapse
 
hm43 profile image
Houda Mouttalib

clean installation thanks!

Collapse
 
ajeetraina profile image
Ajeet Singh Raina

Glad that you liked it. Thanks for referring.

Some comments may only be visible to logged-in visitors. Sign in to view all comments.