VOOZH about

URL: https://thenewstack.io/linux-manage-multiple-versions-of-node-js-with-the-nvm-manager/

⇱ Linux: Manage Multiple Versions of Node.js with the NVM Manager - The New Stack


TNS
SUBSCRIBE
Join our community of software engineering leaders and aspirational developers. Always stay in-the-know by getting the most important news and exclusive content delivered fresh to your inbox to learn more about at-scale software development.
REQUIRED
It seems that you've previously unsubscribed from our newsletter in the past. Click the button below to open the re-subscribe form in a new tab. When you're done, simply close that tab and continue with this form to complete your subscription.
The New Stack does not sell your information or share it with unaffiliated third parties. By continuing, you agree to our Terms of Use and Privacy Policy.
Welcome and thank you for joining The New Stack community!
Please answer a few simple questions to help us deliver the news and resources you are interested in.
REQUIRED
REQUIRED
REQUIRED
REQUIRED
REQUIRED
Great to meet you!
Tell us a bit about your job so we can cover the topics you find most relevant.
REQUIRED
REQUIRED
REQUIRED
REQUIRED
REQUIRED
Welcome!

We’re so glad you’re here. You can expect all the best TNS content to arrive Monday through Friday to keep you on top of the news and at the top of your game.

What’s next?

Check your inbox for a confirmation email where you can adjust your preferences and even join additional groups.

Follow TNS on your favorite social media networks.

Become a TNS follower on LinkedIn.

Check out the latest featured and trending stories while you wait for your first TNS newsletter.

PREV
1 of 2
NEXT
VOXPOP
As a JavaScript developer, what non-React tools do you use most often?
Angular
0%
Astro
0%
Svelte
0%
Vue.js
0%
Other
0%
I only use React
0%
I don't use JavaScript
0%
Thanks for your opinion! Subscribe below to get the final results, published exclusively in our TNS Update newsletter:
NEW! Try Stackie AI
From clobbered drafts to real-time sync
Apr 14th 2026 10:00am, by David Moore
TypeScript 6.0 RC arrives as a bridge to a faster future
Mar 14th 2026 9:00am, by Darryl K. Taft
Mastra empowers web devs to build AI agents in TypeScript
Jan 28th 2026 11:00am, by Loraine Lawson
2022-10-21 10:50:00
Linux: Manage Multiple Versions of Node.js with the NVM Manager
tutorial,
Frontend Development / Linux / Software Development

Linux: Manage Multiple Versions of Node.js with the NVM Manager

With Node.js, you might eventually want to run more than one version of Node on a server. Linux might not like it, but we have a workaround.
Oct 21st, 2022 10:50am by Jack Wallen
👁 Featued image for: Linux: Manage Multiple Versions of Node.js with the NVM Manager

Node.js is a crucial development tool for cloud native development. Because Node.js is very resource-efficient and high performing, it’s perfectly suited for apps and services that need to function at a larger scale. With Node.js, you can develop SaaS applications, such as those used by Netflix, Uber, and Linkedin.

You probably already know what Node.js is. For those of you who do not, it’s an open source server software that runs on almost every platform. An asynchronous, event-driven JavaScript runtime, Node.js is ideal for building scalable network apps and services. Node.js can be used to create very basic applications (such as the always fun “Hello, World” app) to very complex applications.

A sample Node.js web server that serves up the Hello World app might look like this:

const http = require('http');
const hostname = '127.0.0.1';
const port = 3000;

const server = http.createServer((req, res) => {
  res.statusCode = 200;
  res.setHeader('Content-Type', 'text/plain');
  res.end('Hello World');
});

server.listen(port, hostname, () => {
  console.log(`Server running at http://${hostname}:${port}/`);
});

Okay, so it's not nearly as simple as, say, Python, but it's also much more flexible, powerful, and usable in a cloud-native world.

However, during your career with Node.js, there’s one issue you might eventually run into… that of having to work with more than one version of Node. Why is this an issue? Sometimes you might need to build an app that works with an older version of Node.js and other times you might need the new features found in more recent iterations.

That can be a challenge because your operating system might not like the idea of installing more than one version of the language.

Fortunately, there’s a way around that. If your development platform of choice is Linux, you can always turn to the Node Version Manager (aka NVM). With NVM on board, you can easily switch between multiple versions of Node.js on a per-project basis, making certain you have all your bases covered.

Let me show you how to install NVM on Linux. I’ll demonstrate on Ubuntu Server 22.04, which means all you’ll need is a running instance of that distribution (or any Debian-based distro) and a user with sudo privileges. You don’t even need Node.js installed, as you can take care of that task once you have NVM installed.

With that said, let’s get to the steps.

Update/Upgrade

Before we install NVM, let’s first make sure our operating system (and the included software) is up to date.

Log in to your Linux instance (which can be on bare metal or a cloud-hosted service) and update apt with the command:

sudo apt-get update

Once apt is updated, run the upgrade with:

sudo apt-get upgrade -y

Should the kernel be upgraded in the process, you’ll need to reboot the server so the changes take effect.

Install NVM

Now, let’s install NVM. To that, you’ll first need to make sure to install two dependencies with the command:

sudo apt-get install curl gnupg2 -y

With the dependencies installed, download and run the installer script with the command:

curl https://raw.githubusercontent.com/creationix/nvm/master/install.sh | bash

Once the installation is complete, log out and log back in again so everything required is added to your .bashrc file. After logging back in, activate the settings with:

source ~/.bashrc

You can now verify the installation with the command:

nvm --version

You should see something like this:

0.39.1

How to Use NVM

Now that NVM is installed, it’s time to use it. The first thing you’ll want to do is install the most recent version of Node.js with the command:

nvm install node

When the installation completes, you should see something like this in the output:

Computing checksum with sha256sum
Checksums matched!
Now using node v18.10.0 (npm v8.19.2)
Creating default alias: default -> node (-> v18.10.0)

You are now using version 18.10.0 of Node.js.

Let’s install a different version. How about the LTS (Long Term Support) version of Node.js? That’s done with the command:

nvm install node --lts

Let’s say you have a project that requires a version of Node.js that is not the latest version. First, you can find out which versions of Node.js are currently installed with the command:

nvm ls

You should see something like this in the output:

->     v18.10.0
default -> node (-> v18.10.0)
iojs -> N/A (default)
unstable -> N/A (default)
node -> stable (-> v18.10.0) (default)
stable -> 18.10 (-> v18.10.0) (default)
lts/* -> lts/gallium (-> N/A)
lts/argon -> v4.9.1 (-> N/A)
lts/boron -> v6.17.1 (-> N/A)
lts/carbon -> v8.17.0 (-> N/A)
lts/dubnium -> v10.24.1 (-> N/A)
lts/erbium -> v12.22.12 (-> N/A)
lts/fermium -> v14.20.1 (-> N/A)
lts/gallium -> v16.18.0 (-> N/A)

To view a list of all available versions, issue the command:

nvm ls-remote

The output of that command will list a considerable number of versions. Let’s say you have a project that requires version 17.9.1 of Node.js. To use that version, issue the command:

nvm install 17.9.1

Once installed, you can switch to it with the command:

nvm use 17.9.1

The output of the above command should be:

Now using node v17.9.1 (npm v8.11.0)

And there you go, you can now easily install and switch between different versions of Node.js on your Linux machine. For any developer that requires different versions of the language, the NVM tool will be absolutely invaluable for your cloud native development process.

TRENDING STORIES
Jack Wallen is what happens when a Gen Xer mind-melds with present-day snark. Jack is a seeker of truth and a writer of words with a quantum mechanical pencil and a disjointed beat of sound and soul. Although he resides...
Read more from Jack Wallen
SHARE THIS STORY
TRENDING STORIES
SHARE THIS STORY
TRENDING STORIES
TNS DAILY NEWSLETTER Receive a free roundup of the most recent TNS articles in your inbox each day.
The New Stack does not sell your information or share it with unaffiliated third parties. By continuing, you agree to our Terms of Use and Privacy Policy.