How to install Node.js locally with nvm?
Tags: node, npm
Published: 2021-05-16 15:49:49

---
title: How to install Node.js locally with nvm?
published: true
date: 2021-02-28 00:00:00 UTC
tags: node, npm
canonical_url: https://www.mariokandut.com/how-to-install-node-js-with-nvm-node-version-manager/
---

Using the Node.js Version manager (nvm) makes installing and managing multiple versions of Node.js on a single local environment easy. I can only recommend using `nvm`, even if you only need one single version of Node.js, there is a high chance it won't stay like this and switching between different versions is easy.

## [<svg aria-hidden="true" focusable="false" height="16" version="1.1" viewbox="0 0 16 16" width="16"><path fill-rule="evenodd" d="M4 9h1v1H4c-1.5 0-3-1.69-3-3.5S2.55 3 4 3h4c1.45 0 3 1.69 3 3.5 0 1.41-.91 2.72-2 3.25V8.59c.58-.45 1-1.27 1-2.09C10 5.22 8.98 4 8 4H4c-.98 0-2 1.22-2 2.5S3 9 4 9zm9-3h-1v1h1c1 0 2 1.22 2 2.5S13.98 12 13 12H9c-.98 0-2-1.22-2-2.5 0-.83.42-1.64 1-2.09V6.25c-1.09.53-2 1.84-2 3.25C6 11.31 7.55 13 9 13h4c1.45 0 3-1.69 3-3.5S14.5 6 13 6z"></path></svg>](#nodejs-version-manager-nvm)Node.js Version Manager (NVM)

nvm is a version manager for node.js, designed to be installed per-user, and invoked per-shell. It is the preferred way to manage Node.js locally. In a production environment use the operating system package manager, or a server tooling to install and lock your specific version of Node.js.

### [<svg aria-hidden="true" focusable="false" height="16" version="1.1" viewbox="0 0 16 16" width="16"><path fill-rule="evenodd" d="M4 9h1v1H4c-1.5 0-3-1.69-3-3.5S2.55 3 4 3h4c1.45 0 3 1.69 3 3.5 0 1.41-.91 2.72-2 3.25V8.59c.58-.45 1-1.27 1-2.09C10 5.22 8.98 4 8 4H4c-.98 0-2 1.22-2 2.5S3 9 4 9zm9-3h-1v1h1c1 0 2 1.22 2 2.5S13.98 12 13 12H9c-.98 0-2-1.22-2-2.5 0-.83.42-1.64 1-2.09V6.25c-1.09.53-2 1.84-2 3.25C6 11.31 7.55 13 9 13h4c1.45 0 3-1.69 3-3.5S14.5 6 13 6z"></path></svg>](#how-to-install-nvm)How to install NVM

`nvm` works on any POSIX-compliant shell (sh, dash, ksh, zsh, bash), in particular on these platforms: **unix** , **macOS** , and **windows WSL**.

To install or update nvm, run the install script. You can also download it and then run it, but `cUrl` or `Wget` with `bash` pipe are very convenient commands.

```
curl -o- https://raw.githubusercontent.com/nvm-sh/nvm/v0.38.0/install.sh | bash
```

or

```
wget -qO- https://raw.githubusercontent.com/nvm-sh/nvm/v0.38.0/install.sh | bash
```

Running either of the above commands downloads a script and runs it. This script clones the nvm repository into `~/.nvm` and updates your profile (~/.bash\_profile, ~/.zshrc, ~/.profile, or ~/.bashrc) to source the nvm.sh it contains.

After this **restart your terminal** or manually source your ~/.profile, like `source ~/.bash_profile`.

Then verify that it worked, with the command:

```
command -v nvm
```

The command should return `nvm`. Normally we could use `which`, but `nvm` is a shell script and not an application.

Some common trouble shooting tips can be found in the official documentation of [nvm](https://github.com/nvm-sh/nvm#installation-and-update).

### [<svg aria-hidden="true" focusable="false" height="16" version="1.1" viewbox="0 0 16 16" width="16"><path fill-rule="evenodd" d="M4 9h1v1H4c-1.5 0-3-1.69-3-3.5S2.55 3 4 3h4c1.45 0 3 1.69 3 3.5 0 1.41-.91 2.72-2 3.25V8.59c.58-.45 1-1.27 1-2.09C10 5.22 8.98 4 8 4H4c-.98 0-2 1.22-2 2.5S3 9 4 9zm9-3h-1v1h1c1 0 2 1.22 2 2.5S13.98 12 13 12H9c-.98 0-2-1.22-2-2.5 0-.83.42-1.64 1-2.09V6.25c-1.09.53-2 1.84-2 3.25C6 11.31 7.55 13 9 13h4c1.45 0 3-1.69 3-3.5S14.5 6 13 6z"></path></svg>](#how-to-use-nvm)How to use nvm

After successful installation, we can type in `nvm` to get a list of available commands. We start with installing the latest LTS version of Node.js.

```
nvm install --lts
```

The output should look similar like this:

![Installing latest Node.js version with NVM](https://www.mariokandut.com/static/15da29c00bc0098df4ad17d7f9cc5540/fcda8/node-nvm.png "Installing latest Node.js version with NVM")

The last line says `now using node v14.7.0`, which means that nvm is set to use Node.js version 14.7.0. We can verify by typing `node --version`.

If you want to install a different Node.js version, just use `nvm ls-remote` to **list all versions** and install it `nvm install <VERSION>`, <version> would be a placeholder for the version number.
After installing it, you have to tell nvm to use it with <code>nvm use &lt;VERSION&gt;</code>. Verify with <code>node -v</code>.</version>

## [<svg aria-hidden="true" focusable="false" height="16" version="1.1" viewbox="0 0 16 16" width="16"><path fill-rule="evenodd" d="M4 9h1v1H4c-1.5 0-3-1.69-3-3.5S2.55 3 4 3h4c1.45 0 3 1.69 3 3.5 0 1.41-.91 2.72-2 3.25V8.59c.58-.45 1-1.27 1-2.09C10 5.22 8.98 4 8 4H4c-.98 0-2 1.22-2 2.5S3 9 4 9zm9-3h-1v1h1c1 0 2 1.22 2 2.5S13.98 12 13 12H9c-.98 0-2-1.22-2-2.5 0-.83.42-1.64 1-2.09V6.25c-1.09.53-2 1.84-2 3.25C6 11.31 7.55 13 9 13h4c1.45 0 3-1.69 3-3.5S14.5 6 13 6z"></path></svg>](#tldr)TL;DR

- **nvm** is an easy way to manage multiple versions of Node.js
- nvm is a shell script and invoked per shell.
- Install a Node.js version with `nvm install <VERSION>`
- Use an installed Node.js version with `nvm use <VERSION>`

Thanks for reading and if you have any **questions** , use the **comment** function or **send me a message** **[@mariokandut](https://www.twitter.com/mariokandut)**.

If you want to know more about **[Node](https://www.mariokandut.com/tags/node)**, have a look at these [Node Tutorials](https://www.mariokandut.com/tags/node).

### [<svg aria-hidden="true" focusable="false" height="16" version="1.1" viewbox="0 0 16 16" width="16"><path fill-rule="evenodd" d="M4 9h1v1H4c-1.5 0-3-1.69-3-3.5S2.55 3 4 3h4c1.45 0 3 1.69 3 3.5 0 1.41-.91 2.72-2 3.25V8.59c.58-.45 1-1.27 1-2.09C10 5.22 8.98 4 8 4H4c-.98 0-2 1.22-2 2.5S3 9 4 9zm9-3h-1v1h1c1 0 2 1.22 2 2.5S13.98 12 13 12H9c-.98 0-2-1.22-2-2.5 0-.83.42-1.64 1-2.09V6.25c-1.09.53-2 1.84-2 3.25C6 11.31 7.55 13 9 13h4c1.45 0 3-1.69 3-3.5S14.5 6 13 6z"></path></svg>](#references-and-big-thanks)References (and Big thanks):

[Node.js](https://nodejs.org/), [HeyNode](https://heynode.com/tutorial/install-nodejs-locally-nvm)