NVM - a Node.js Version Manager

By Łukasz Kallas
Picture of the author
Published on
nodejs image

Node.js, a cross-platform JavaScript runtime environment, is constantly updated. While writing this post, the latest version is 22.

In your daily work as a developer, you might face challenges with legacy systems or microservice architectures that use many different versions of Node.js. You can have some apps running v10, others v16 and in the meantime you are writing in v20.

To keep all these versions under control and ensure compatibility and proper functioning, you sometimes need to switch the Node.js version in your local environment, and that's where NVM, a Node.js Version Manager comes in!

Installation

If you are using Linux or OS X then installation consist just of few basic steps of downloading and running an install script. For the official project site, you can go to https://github.com/nvm-sh/nvm.

On the other hand, if you are using Windows, there is a windows project that you can find at https://github.com/coreybutler/nvm-windows.

I don't want to put the specific copy & paste link here so that no matter when you read this post, you would get always up to date link with newest version from the official repository.

Installation may vary slightly between operating systems, but the usage remains consistent.

Usage

Usage itself is just as simple as few basic commands:

  • install specific node.js version
briefly:~ lukasz$ nvm install 22.1.0
Downloading and installing node v22.1.0...
Downloading https://nodejs.org/dist/v22.1.0/node-v22.1.0-darwin-x64.tar.xz...
############################################################################################################################################# 100.0%
Computing checksum with shasum -a 256
Checksums matched!
Now using node v22.1.0 (npm v10.7.0)
  • list all installed versions
briefly:~ lukasz$ nvm list
       v10.15.0
      v12.22.12
       v16.13.0
       v16.20.1
       v18.16.1
        v20.9.0
->      v22.1.0
  • switch currently used version
briefly:~ lukasz$ nvm use 20.9.0
Now using node v20.9.0 (npm v10.1.0)

So simple and efficient! See you tomorrow in another post.

Stay Tuned

Want to learn?
The best articles, links and news related to software development delivered once a week to your inbox.