Categories: Ubuntu

How to Downgrade the Node Version on Ubuntu?

NodeJS is a well-reputed open-source JavaScript environment that can be run on wide platforms like macOS, Linux, Windows, and much more. Its main objective is to execute the JavaScript code outside the browser. It also helps to build scalable and fast server-side dynamic network applications based on the JavaScript programming languages.

In some situations, the user needs to use the specific node version for building and modifying the node.js application as per requirements. For this purpose, the user upgrades or downgrades the node version according to the application’s needs and specifications.

This guide will provide a complete procedure to downgrade the node version on Ubuntu.

How
Sponsored
to Downgrade Node Version on Ubuntu?

To downgrade the node version on Ubuntu, use the “n” command. This command installs, activates, and removes the node version immediately. Moreover, it can also manage the different node versions in the Linux operating systems easily.

This section carries out the practical implementation of “n” command to downgrade the node version on Ubuntu using the given steps of instructions.

Step 1: Check Node Version
Firstly, check out the already installed node version by specifying its name like “node” with the “version(v)” flag:

node v

The installed node version is “v18.17.1”:

Step 2: Install “n” in Ubuntu
Next, execute the following installation command with the administrative privileges to install the “n” command globally in the Ubuntu system:

sudo npm install -g n

In the above command, the “npm” keyword refers to the “node package manager ” and the “sudo” denotes the administrator.

The following output confirms that the “n” package has been added to the current OS:

Sponsored

Step 3: Install Downgrade Node Version
Now, use the “n” command to install any older/downgrade node version in the Ubuntu operating system:

sudo n 10.16.0

Here, the output shows that the specified node version has been installed successfully in Ubuntu. Now, the current Ubuntu OS maintains both older and newly installed node versions placed at the specified path:

In the above output, the purpose and use of the highlight “hash -r” command are discussed in the next step.

Step 4: Verify Downgraded Node.js Version
Before the verification of a newly installed node, it is recommended to start a new shell or reset the location of the node using the “hash” command along with the “-r” flag. It forgets all the remembered location from the hash table because the current shell will not show the newly installed node version until it clears the existing node location:

hash r
node v //Checking Node version

After clearing the hash table of the current Ubuntu system, the version command shows the newly installed downgraded version of the node:

Hence it is verified that the node “v18.17.1” version has been downgraded to “v10.16.0”.

That’s all about downgrading the Node version on Ubuntu.

Conclusion

To downgrade the node version on Ubuntu, use the “n” command. It is not the built-in command so the user first needs to install it into the Ubuntu OS through the “npm” package manager and then utilize it for downgrading the node version. It switches the node version in the form of upgradation or downgradation. This guide has described the complete procedure to downgrade the node version on Ubuntu.

Ubuntu Server Admin

Recent Posts

Web Engineering: Hack Week 2024

At Canonical, the work of our teams is strongly embedded in the open source principles…

20 hours ago

Ubuntu Weekly Newsletter Issue 873

Welcome to the Ubuntu Weekly Newsletter, Issue 873 for the week of December 29, 2024…

3 days ago

How to resolve WiFi Issues on Ubuntu 24.04

Have WiFi troubles on your Ubuntu 24.04 system? Don’t worry, you’re not alone. WiFi problems…

3 days ago

Remembering and thanking Steve Langasek

The following is a post from Mark Shuttleworth on the Ubuntu Discourse instance. For more…

3 days ago

How to Change Your Prompt in Bash Shell in Ubuntu

I don’t like my prompt, i want to change it. it has my username and…

3 days ago

The Silent Guardian: Why Bundler Checksums Are a Game-Changer for Your Applications

Introduction: A Fragile Trust The Ruby ecosystem relies heavily on RubyGems.org as the central platform…

4 days ago