JavaScript

How to downgrade or upgrade the node version?

Whenever you are building some node js application, you will have to work on some specific version as many organizations are using some specific version of node js for building the applications, hence you might always need to upgrade or downgrade your node version according to the requirements.

In this article, we are going to discuss how you can simply upgrade or downgrade the node js version using some simple tricks and commands.

What is Node?

Without the need for a web browser, Node.js runs JavaScript code. Node.js is quite popular due to its cross-platform nature since it can be used as Node.js on Windows or Node.js on Mac. As a result, Node packages may be utilized in the creation of mobile apps. In some situations, you may utilize Node.js for iOS programming or Android development.

Since Nodejs has an active community of users, minor updates come out after every few weeks.

What is NPM?

The npm is the default package manager for Node.js and is used to manage javascript packages and modules. npm register and the command line interface is being used.

What is Yarn?

Yarn is also a package manager for npm and also works the same as npm, it can also be used to manage and control the node packages like installing modules and controlling the version etc.

How to install Node?

To get started with Node.js, visit NodeJS official website and download the Node.js installer for Windows, macOS, or Linux. If you have a really particular deployment target, you may even obtain the source code and assemble it yourself.

How to Downgrade or Upgrade Node.js

You may verify the node version using the node -v command in the terminal before doing any activity. Then you may update Node using one of the ways listed below. You may also pick a certain node version or degrade it. By supplying a version in the associated instructions, you can downgrade the node version.

Update the node version using installers

Visit the official website of the Node and there you will find out the latest and a stable version of the node hence you can download it from there.

Updating Node.js using npm

To use npm to update Node, you must first install the n module:

Clean up the npm cache:

npm cache clean -f

Then you may install the most recent version of Node: n stable or To install, choose one of the following versions: n [version-number] – the version number might be anything from 614.9 to v8.1.2.

 

Upgrading/Downgrading Node using nvm:

nvm is another useful tool that can help you to control the node version itself, you can use nvm commands to upgrade the node version quite easily.

you can simply install the nvm package and that’s it from your side now you nvm is responsible for controlling your node version. Whenever you need to upgrade or downgrade a node version you can simply type a few commands given below and that’s it.

Let’s take a look at how we can easily upgrade or downgrade the node version using nvm.

use the below command to install the latest node version using nvm.

$ nvm install node

for installing a specific version of the node you can type the following command

$ nvm install <version-number>

Here the version-number is the version of the node which you will be installing particularly.

for example

$ nvm install 12.18.2

output

Similarly you can downgrade your node version to the specific version you want by just typing the version number in the above described command and that’s it.

Conclusion

Nodejs can be upgraded or downgraded using different methods some of them are by manually downloading the latest version of node from their official nodejs.org website and the second method is by using nvm which is really helpful in controlling the node version. you can simply type the above discussed command and install the specific versions of the node and latest version of the node as well.

About the author

Shehroz Azam

A Javascript Developer & Linux enthusiast with 4 years of industrial experience and proven know-how to combine creative and usability viewpoints resulting in world-class web applications. I have experience working with Vue, React & Node.js & currently working on article writing and video creation.