By Shivani Makwanaauthor-img
July 31, 2025|8 Minute read|
Play
/ / A Comprehensive Guide on Changing Node.js Version
At a Glance:

Managing and upgrading Node.js versions is indeed a crucial skill for programmers working on multiple projects. The blog talks about primary tools like NVM for macOS/Linux and nvm-windows for Windows users to install, upgrade, downgrade, and uninstall node js versions. The blog also covers additional tips and troubleshooting some common issues to help you ensure the project’s stability and efficient development workflows.

Managing Node.js versions is a crucial skill developers require when working on several projects or staying current with the fast-changing JavaScript world. Different projects may require a specific version of Node.js because of features, compatibility, or performance improvement in newer releases.

This detailed guide explains the primary methods for upgrading or downgrading your Node.js version. The blog also highlights well-known tools like NVM, troubleshooting, and best tips to upgrade and downgrade your node version. Let’s have a look.

Introduction

Node.js works as an open-source JavaScript runtime that people use for backend work or developing tools. It often gets updates with important features or fixes for security. But sometimes certain libraries, frameworks, or hosting setups need you to use older or very specific versions of Node.js. Being able to switch between different Node.js versions is important to:

  • Keep your projects running with the right dependencies. 
  • Handle older code that wasn’t updated.
  • Try out new features without messing things up. 
  • Prevent errors or issues caused by version conflicts.

Prerequisite Before Switching Node Version

  • Know the basics of using the command line. 
  • Make sure you have admin or root permissions if the task requires it.
  • Save your work and back up your current Node.js setup just in case.

1. Using Node Version Manager (NVM) for macOS and Linux

First, let’s understand what NVM is.

NVM is a tool you use in the terminal. It lets you manage multiple Node.js versions on your computer. You can install, update, remove, or switch between versions. It helps with:

  • Allowing simple Node.js version management. 
  • Separating versions so each has its own global modules. 
  • Letting you set specific versions for individual projects.

How to Install NVM?

Launch your terminal and type in the following command.

curl -o- https://raw.githubusercontent.com/nvm-sh/nvm/v0.40.1/install.sh | bash 

or (the latest version may differ):

wget -qO- https://raw.githubusercontent.com/nvm-sh/nvm/v0.40.1/install.sh | bash 

After installation, either restart your terminal or run:


export NVM_DIR="$HOME/.nvm"

[ -s "$NVM_DIR/nvm.sh" ] && \. "$NVM_DIR/nvm.sh"

Verify NVM:

nvm --version 

Installing Node.js Versions (Upgrade/Downgrade)

  • List Available Node.js Versions
nvm ls-remote

This will output all Node.js versions available for installation. 

  • Install a Specific Version 

To install a specific version (e.g., 20.18.0):

nvm install 20.18.0 

You can also install the latest LTS version:

nvm install --lts

Or the very latest version:

nvm install node
  • Switch Between Installed Versions 

See all installed versions:

nvm ls

To use a specific version:

nvm use 16.20.2

Or switch by major/minor version if only one matches:

nvm use 14 
  • Set Default Node.js Version 

To always start a shell session with a particular Node.js version:

nvm alias default 20.18.0
  • Uninstall a Node.js Version 

To remove unused versions and free space: 

nvm uninstall 14.21.3
  • Upgrading Node.js 

Upgrading is just another install/switch:

nvm install 21.0.0 
nvm use 21.0.0 
nvm alias default 21.0.0
  • Downgrading Node.js 

Downgrading is the same process—just pick an older version:

nvm install 16.20.0 

nvm use 16.20.0

Downgrade when a library or project fails with a new Node release. 

2. Using Node Version Manager on Unix or macOS

NVM works as a quick and easy tool to manage Node.js versions on Unix-based systems. It takes up less space compared to nvm but offers fewer settings to adjust.

  • Check your current version  

Run the following command  

node –v

Upgrade Node.js version  

  • Install n Globally 

npm install -g n

To upgrade to the latest version:

sudo n latest

For the latest LTS:

sudo n lts

For a specific version:

sudo n 18.16.0
  • Downgrade Node.js Versions (Switch to a Specific Version) 

To install specific version: 

sudo n 18.16.0

Choose among installed versions: 

sudo n 

This opens an interactive menu to pick your Node version.

  • Getting Rid of Old Versions

Use sudo n to open the menu and remove outdated versions you no longer need. 

3. Working with Node.js Versions on Windows (nvm-windows) 

Windows requires a specific version of NVM, called nvm-windows, to manage Node.js versions.

Setting Up nvm-windows

  • Grab the latest installer from the nvm-windows releases page.
  • Run the installer to complete the setup by following the steps. 
  • The default way to run NVM commands is through a command prompt.

Adding, Updating, or Downgrading Node.js

  • To upgrade Node.js version 20.18.0:

nvm install 20.18.0 
  • List all installed versions:
nvm list
  • To downgrade/switch a version:
nvm use 16.15.1
  • Set the default version:
nvm use 20.18.0
  • Remove a version:
nvm uninstall 14.18.3

Notes

nvm-windows allows you to manage Node and npm. When you change the Node version, it installs a new copy of npm suited to that specific Node.js version.

In 2025, nvm-windows remains a stable and trusted tool, but there are plans to release a "Runtime" tool in the future. 

Other Approaches (Homebrew, Apt, Volta)

  • Homebrew (macOS): 

brew install node         # To install 

brew upgrade node         # To upgrade 

brew uninstall node       # To remove 

node -v                   # Verify
  • Apt (Ubuntu/Debian): 

Update with NodeSource (choose your target version, e.g., 20.x):

curl -fsSL https://deb.nodesource.com/setup_20.x | sudo -E bash - 

sudo apt install nodejs
  • nodeVolta

Volta works as a modern tool to manage Node.js and Yarn/npm across different platforms. It keeps track of projects and locks specific versions to each one. This makes it a good choice to meet the needs of diverse teams.

  • For installing Volta: 

curl https://get.volta.sh | bash
  • Install a specific Node.js version:

volta install node@20.18.0
  • Pin for a project (from project directory):

volta pin node@20.18.0 

4. Checking and Handling Global npm Packages

Each Node.js version manages a separate global storage for npm packages when using NVM or n. Switching Node.js versions will require reinstalling global tools like Gatsby CLI or nodemon using the following command: 

npm install -g your-global-package

To upgrade npm for any Node.js version:

npm install -g npm 

npm -v

 

5. Without nvm (Manually Upgrading or Downgrading Node.js)

You can try this method, but it is not the best option:

  • Go to the official Node.js website and grab the installer. 
  • Use the installer to set up the version you want.
  • This method will overwrite your Node.js version, making it trickier to handle different versions across projects.

6. Troubleshooting 

Permission problems: On Linux or macOS, check if nvm directories have the right permissions. Avoid using sudo too often.

nvm not found: Ensure nvm is sourced in your shell. Add to ~/.bashrc or ~/.zshrc

export NVM_DIR="$HOME/.nvm" 

[ -s "$NVM_DIR/nvm.sh" ] && \. "$NVM_DIR/nvm.sh"

npm issues: Clear the npm cache if packages fail to install:

npm cache clean --force

Issues with PATH: If your terminal says node or npm cannot be found, try restarting it or check if your environment variables are set up. 

7. Additional Tips 

Some additional tips to consider when upgrading or downgrading node.js versions.

  • Do not use sudo while working with nvm unless there is no other option. Always manage installs or updates as a regular user unless instructed otherwise. 
  • Get rid of old or unnecessary Node versions using nvm uninstall. You can also delete extra installations done via package managers or direct downloads. 
  • When switching Node versions, check if your global npm packages are still in place.
  • To avoid mistakes in team environments, use .nvmrc files or tools like Volta for keeping configurations streamlined. 

Summary Table

Action  Command Example 

Install nvm  

`curl -o- ... 

Install Node version  

nvm install 18.17.0 

Use Node version  

nvm use 18.17.0 

Downgrade 

nvm install 14.21.3 && nvm use 14.21.3 

See the current version  

node -v 

Set default  

nvm alias default 18.17.0 

Concluding

Understanding how to manage Node.js versions is an important skill. Tools like NVM or nvm-windows give you the flexibility you need to switch versions and keep your development up-to-date. You might need to update to newer versions to access features. You might also need older versions to support older systems. Good version management will help your team avoid problems and save time.

Make a habit of clearing out old Node versions that you no longer use. Write down what each project requires and use tools like Volta pinning to keep your team on the same page.

To stay ahead with the latest tools and updates, including new cross-platform managers or tools like Runtime, check the Node.js release blog or other reliable developer sites.

Need professional guidance for your node.js version? Look no further, Lucent Innovation got you covered. Hire node.js developers from us and get the right technical assistance to turn your project into a reality.

Shivani Makwana

One-stop solution for next-gen tech.

Frequently Asked Questions

Still have Questions?

Let’s Talk

What is NVM - Node Version Manager?

arrow

Is NVM similar to NPM, Yarn, or PNPM?

arrow

Can different versions of NodeJS be installed and managed without NVM?

arrow

Which Node.js version manager is the best?

arrow

How to resolve permission errors when changing versions of Node.js?

arrow

How to check which Node.js version is compatible with my project?

arrow