How to Downgrade to a Previous Node.js Version Using NVM

With the release of new Node.js versions, it’s not uncommon for you to encounter compatibility issues with the existing dependencies. In such cases, you may need to downgrade the Node.js version you’re using to a more suitable one to ensure your application works as expected.

Learn about the steps you should take to downgrade your version of Node.js.

4

Understanding the Node.js Versioning System

Not all Node.js releases are equal. While newer versions offer improved performance and new features, they may also introduce breaking changes that could cause issues with your code. When choosing a previous version, select the one that’s stable and compatible with the dependencies you’re using in your app.

LTS releases are versions that are supported for an extended period and receive regular updates, including security fixes and bug patches. Current releases, on the other hand, are intended for developers who want to use the latest features and improvements. When choosing a Node.js version to use, keep this in mind.

a person holding a Node.js sticker

Using NVM to Manage Node.js Versions

The Node Version Manager (NVM) lets youinstall and switch between multiple Node.js versionswith ease. It lets you install packages and dependencies specific to each Node.js version. This means that you can have different sets of packages and dependencies for each project, depending on the Node.js version it requires.

This approach is better than installing and uninstalling Node every time you need a specific version.

Article image

Before using NVM, you must install it. Visit theofficial NVM GitHub repositoryand follow the instructions to install NVM in your operating system.

After installing NVM, verify that it’s working correctly by running this command:

An iPhone is shown with the account section grayed out in the settings menu

If you’re on Windows, you may need to restart the operating system or run this command as an administrator on the command prompt.

Now that you have NVM installed, you’re able to use it to manage your Node.js versions. The following are basic steps to install Node.js version 17.9.1.

Samsung Galaxy S24 Ultra and iPhone 11 next to each other

Open a terminal or command prompt. Then, use the nvm install command followed by version number 17.9.1.

Once the installation is complete, use the command nvm use followed by the version number to switch to the installed Node.js version.

Verify that the correct Node.js version is being used by running the command node -v in the terminal or command prompt:

This should display the version number of the Node.js version you just installed.

Switching Between NVM Versions

As previously stated, one of the main advantages of using NVM is the ability to easily switch between Node.js versions as needed.

To get started, use the nvm ls command to list all the Node.js versions installed on your machine.

The output of the nvm ls command includes the version number and whether that version is currently in use.

You can now use the commandnvm usefollowed by the version number to downgrade to the desired Node.js version.

Creating an Alias for Node.js Versions

If you frequently reference a certain Node.js version for your projects, you may find a short alias easier to remember and type.

To create an alias for a specific version of Node.js using NVM, use the nvm alias command. For example, to create an alias called default17 for Node.js version 17.9.1, run the following command:

Now, instead of typing outnvm use 17.9.1every time you want to switch to that version, you can usenvm use default17.

If you want to remove this alias, use the nvm unalias command:

Different applications may be compatible with different Node.js versions. If you need to downgrade to a previous version or even upgrade to the latest one, use NVM.

NVM will help you install multiple Node.js versions and switch between them on a per-project basis. This way, you avoid any incompatibility issues.

Want to install multiple versions of Node.js on your Linux machine? Here’s what you need to know about NVM.

Turn these settings on, and your iPhone will be so much better than before.

Your phone’s camera app doesn’t show this, so it’s easy to miss.

Flagship price, mid-range phone.

Sometimes the smallest cleaning habit makes the biggest mess.

Free AI tools are legitimately powerful; you just need to know how to stack them.

Technology Explained

PC & Mobile