Thanks to visit codestin.com
Credit goes to github.com

Skip to content

GreetVdL/NVMtutorial

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

24 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

NVM tutorial

What is nvm?

NVM stands for Node Version Manager.

---> cfr. the nvm repo on GitHub stating that "nvm allows you to quickly install and use different versions of node via the command line."
More elaborately explained there, "nvm is a version manager for node.js, designed to be installed per-user, and invoked per-shell. nvm works on any POSIX-compliant shell (sh, dash, ksh, zsh, bash), in particular on these platforms: unix, macOS, and windows WSL."
In the above mentioned repository you will also find an installation guide, or go and check the nvm repo for Windows for guidelines on installation on a Windows computer.
This guide concerns the working of the former, so not the version of nvm made for Windows.

Once installed correctly, you can check the version of nvm in use with:
nvm -v

NVM usage

The 'nvm install' command

  • Install a specific version of node, for example version 12.14.1:
    nvm install 12.14.1
  • Installs what is currently the newest version:
    nvm install node
  • Install the latest LTS version:
    nvm install --lts
  • Uninstall version 12.14.1:
    nvm uninstall 12.14.1

npm

Each time nvm installs a Node.js instance, nvm will also install a compatible npm version.

  • To check which version of npm you're currently using, run:
    npm -v

For each node version, NVM stores the globally installed npm packages seperately. This prevents incompatibilities as things could break. They’re installed alongside the current Node version in ~/.nvm/versions/node/<version>/lib/node_modules.

  • But if you wish, you can reinstall the npm global packages from a specific version when installing a new Node.js version. For example:
    nvm install v12.14.1 --reinstall-packages-from=10.18.1
    By running the above, nvm will install Node.js version 12.14.1, the exact version of npm required, and reinstall the global npm packages you had installed for the 10.18.1 version.

Node.js versions

  • To check which version of node you're currently using, run:
    nvm current

  • For finding the path to a specific installed node version, for example version 12.14.1, run:
    nvm which 12.14.1

  • If you want to check which versions you have installed:
    nvm ls

The 'nvm use' command; switching between versions

  • When you install a specific version of Node.js, nvm will automatically put it to us. You can check this with the command
    node -v.

  • Switch to Node.js version 12.14.1;
    nvm use 12.14.1

  • Switch to the latest Node.js version:
    nvm use node

  • Switch to the latest LTS version:
    nvm use --lts

Using aliases

  • You can create an alias for a specific version, for example:
    nvm alias favorite-version 12.14.1
    Then, run:
    nvm use favorite-version

  • You can delete that alias, by running:
    nvm unalias favorite-version

Default version

  • You can also choose a specific node version to be set as the default instance to be used. For example:
    nvm alias default 12.14.1

About

An NVM guide for beginners

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published