Home > Web Front-end > JS Tutorial > How to upgrade nodejs version

How to upgrade nodejs version

青灯夜游
Release: 2021-11-05 17:13:10
Original
31711 people have browsed it

Upgrade method: 1. Use the "npm cache clean -f" command to clear the npm cache; 2. Use the "npm install -g n" command to install the n module; 3. Use the "n version number" command to upgrade to the specified version, or use the "n stable" command to upgrade to the latest stable version.

How to upgrade nodejs version

The operating environment of this tutorial: CentOS 6 system, nodejs version 12.19.0, DELL G3 computer.

The development of Node.js is very active, and its latest stable version also changes frequently. From time to time, you will find that a module cannot be used on your current Nodejs version. At this time, you need to upgrade the Nodejs version. So how to upgrade?

You can use the Node Binary management module "n" to upgrade the nodejs version. Let's take a look at the upgrade steps:

1. Install the n module

Check the current node version:

node –v
Copy after login

Clear npm cache

npm cache clean -f
Copy after login

Install n module:

npm install -g n
Copy after login

2. Upgrade the Nodejs version

Upgrade to the specified version/latest version (this step may take some time). Before upgrading, you can execute n ls (to view the upgradeable versions), such as:

n 6.9.1
Copy after login

Or you can Tell the manager to install the latest stable version

n stable
Copy after login

After the installation is completed, check the version of Node and check whether the upgrade is successful

node -v
Copy after login

Note: If the version information obtained is incorrect, you You may need to restart the machine

[Recommended learning: "nodejs tutorial"]

The above is the detailed content of How to upgrade nodejs version. For more information, please follow other related articles on the PHP Chinese website!

Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template