How to upgrade nodejs to a lower version


Nodejs is a runtime platform based on the Chrome JavaScript engine, which utilizes features such as event driven and non blocking I/O, making it an efficient server-side platform. In actual development, we may encounter situations where we need to switch versions of nodejs. This article will introduce how to switch versions in nodejs.

NVM, a version management tool for nodejs

NVM is a git based nodejs version management tool, similar to RVM in Ruby or Jenv in Java. It can easily perform operations such as switching, installing, and uninstalling Node.js versions.

Installing NVM

Before starting to use NVM, we need to install NVM on the system. In Linux, the curl command can be used for installation, as follows:

Curl - o- |Bash

In Windows, you can access the official website of NVM( )Download the nvm file for installation.

Using NVM

After installing NVM, we can take a look at how to use it.

List available nodejs versions: nvm ls remote

Install the specified version of nodejs: nvm install 8.0.0

Use the specified version of nodejs: nvm use 8.0.0

Uninstall the specified version of nodejs: nvm uninstall 8.0.0

Set nodejs default version: nvm alias default 6.0.0

It should be noted that for Windows systems, by default, NVM does not automatically add nodejs to the system environment variable and needs to be manually added. Add can be found in the installation directory of NVM_ To_ Path.cmd and rm_ From_ Two files, path.cmd, can be used to add or remove the path of node.js by executing these scripts.

Managing nodejs versions through NVM is very convenient and can also avoid conflicts caused by multiple projects requiring different versions of nodejs.

Manually switch nodejs version

The above introduces the use of NVM, but in some cases, we may not want to use NVM for version switching and instead want to manually switch the nodejs version. So how should we proceed with this operation?

Firstly, you need to download the required version of the nodejs installation package and extract it to the specified directory.

Then, we can manually switch by setting system environment variables. In Linux, the bin directory of nodejs can be added to $PATH, such as:

Export PATH=$PATH:/path/to/nodejs/bin

In Windows, it is necessary to manually add the path of nodejs to the system environment variable.

When switching the nodejs version, simply execute the commands set above in the terminal.

Copyright Description:No reproduction without permission。

Knowledge sharing community for developers。

Let more developers benefit from it。

Help developers share knowledge through the Internet。

Follow us