Node.js Installation with NVM

If you’re using macOS, Linux or Windows Subsystem for Linus (WSL), this quick guide will help you to set up your Node.js development environment.

Please note that nvm will not work with Windows unless you are using WSL.

Question thought bubble

What’s the difference between npm and nvm?

NPM or Node Package manager is usually used as a command-line utility that aids in installing packages (node.js libraries), and managing their versions and dependencies.NVM or Node Version Manager is a bash script that is used to manage active node.js versions.

Why would I need NVM?

Consider this, you need to work with a project that is using an older version of Node, or you want to see what the latest version has to offer. Does that mean you have to run through the process of installing and uninstalling versions of Node.js and interrupt your dev flow? Certainly not.

NVM allows you to:

  • Download and access any remote Long Term Support (LTS) version of node locally
  • Switch between different version of installed node easily
  • Choose your default version of node
  • and more…

Sounds good? Let’s get started.

Person typing


1. Open a new Terminal window

2. Install NVM

Using Curl:

curl -o- | bash

Using wget:

wget -qO- | bash

3. Close the terminal window and open a new one.

4. If everything went as planned, you should now be able to verify the installation

command -v nvm

5. You can also check if it was installed by checking the version of nvm

nvm --version

6. If you get an error message, you may need to do some manual configuration

a. You may need to edit your profile (~/.bash_profile, ~/.zshrc, ~/.profile, or ~/.bashrc) by adding the following:

export NVM_DIR="$HOME/.nvm"[ -s "$NVM_DIR/" ] && . "$NVM_DIR/"  # This loads nvm[ -s "$NVM_DIR/bash_completion" ] && . "$NVM_DIR/bash_completion"  # This loads nvm bash_completion

b. Reload your shell by running

source ~/.bashrc

or open a new terminal window and do step 4.

Let’s take it for a spin

1. List the version(s) of node currently installed

nvm ls

2. Install the latest LTS version

nvm install --lts

3. Install the latest version of node

nvm install node

4. Use the latest LTS version of node

nvm use --lts

5. Use the latest version of node

nvm use node

6. Install a specific version of node

nvm install 10.16.3

7. View all available remote versions of node

nvm ls-remote

8. Change the default version of node (you can change the version number to suit your needs. eg 10.16.3 or 12.11.0)

nvm alias default v10.16.3

9. Delete a version of node

nvm uninstall v12.10.0

References: Github, NVM

This post was created with our nice and easy submission form. Create your post!

What do you think?

27 points
Upvote Downvote

Written by Karen H

Rachel Villeda

Dev Interview: Rachel Villeda

Dev Interview: Juan Lopez