Source

Managing Node.js via NVM

Fardeen Khan
Code Panthers
Published in
3 min readMar 12, 2022

--

Node.js is a fast-developing tool, rolling out updates, both minor and major, at a rather alarming rate compared to other technologies. This combined with the possible incompatibility of projects across versions/packages may lead to your code becoming obsolete with time.

You can of course have as many node versions installed as required by your current or legacy projects. But it does become a pain after a while. For me it hits pretty hard on the second installation itself. Hence I prefer to go with a version manager

Node Version Manager aka NVM

As the name goes, it simply manages the multiple versions of node installed on your system. Listing down a few advantages it has over the manual way

  • Offers a robust CLI experience to list remote, and LTS versions and install/remove any of the versions
  • Easily switch between any of the versions locally. There can be only one version active at a time globally (Sorry but no virtual environment packaged with your code)
  • Dont like version numeric, heck just add an alias to the versions

I hope I have convinced you to leave the stupid habit of downloading installers and scratching your head when you see a project based on a different node version.

Regardless let's carry on to the actual installation and usage of the tool

Installation

  • Linux and macOS: Use a handy install script. Use either of the two commands
  • Windows: The default nvm is missing from the Windows platform but thankfully, a community member ported the same for Windows. You can download it from here

Done with the installation? Great let's actually use it

Note — You may need to restart the terminal or the .bashrc file for the command to be available

Commands

// Fetch list of remote and local versions
nvm list
// Install latest version
nvm install node
// Install specific version
nvm install 16.14.0
// Switch to a global version
nvm use <version>
// Install and use LTS versions
nvm install --lts
nvm use --lts

Well, that covers all the basics. Hope you liked it. Drop a like and share the article if you found it helpful. Thanks !!!!!

--

--