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:
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.
for installing a specific version of the node you can type the following command
Here the version-number is the version of the node which you will be installing particularly.
for example
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.