Using Node Version Manager nvm

suggest change

nvm is a bash script that installs and switches Node.js versions. The old creationix/nvm URL now points at that repository. Do not pin the 2016 install script at v0.31.3. Use the install command in the current README.

# see https://github.com/nvm-sh/nvm#installing-and-updating

For windows there is a nvm-windows package with an installer. This GitHub page has the details. nvm on is an nvm-windows command. The bash nvm has no nvm on.

Note: You may need to restart your terminal for it to recognize the newly installed nvm command.

Then install the latest Node version:

$ nvm install node

You can also install a specific Node version, by passing the major, minor, and/or patch versions:

$ nvm install 6
$ nvm install 4.2

To list the versions available for install:

$ nvm ls-remote

You can then switch versions by passing the version the same way you do when installing:

$ nvm use 5

You can set a specific version of Node that you installed to be the default version by entering:

$ nvm alias default 4.2

To display a list of Node versions that are installed on your machine, enter:

$ nvm ls

To use project-specific node versions, you can save the version in .nvmrc file. This way, starting to work with another project will be less error-prone after fetching it from its repository.

$ echo "4.2" > .nvmrc
$ nvm use
Found '/path/to/project/.nvmrc' with version <4.2>
Now using node v4.2 (npm v3.7.3)

When Node is installed via nvm we don’t have to use sudo to install global packages since they are installed in home folder. Thus npm i -g http-server works without any permission errors.

Feedback about page:

Feedback:
Optional: your email if you want me to get back to you:



Table Of Contents