Correct operation of node.js/npm upgrade (both windows and Linux)

Time:2021-7-27

Original address:https://www.wjcms.net/archives/nodejsnpm Correct operation of windows and Linux upgrade

Today, let’s summarize the correct operation of node.js and NPM upgrade.
Xiaobian’s personal experience can use the following steps to solve the node version problem and the skipped pit. Please pay attention to the problem and click like!

The installation is relatively simple. There is no demonstration here. The official address is attached:https://nodejs.org/zh-cn/

In general, we choose to update the node first, and then follow the new NPM

Update under Windows system

You may find some tutorials on the Internet, but you will report errors

Git BASH (MSYS) is not supported by n
 Error: no version found for 'latest'

Because the N module does not support windows
Therefore, you can only download the latest version from the official website and install it.
Official website:https://nodejs.org/zh-cn/
Note that here you can look at the environment variables and overwrite the path before installation.

The specific steps are:
My computer — right click — properties — advanced — environment variables
Then check the path to find the path of nodejs. During installation, select this path to overwrite the installation.

Update under Linux system

Run first

npm install n -g

Install n dependent packages
Before that, you can configure Taobao image

npm config set registry https://registry.npm.taobao.org

In this way, you can use CNMP installation to greatly improve the installation success rate and speed. You can use cnpm command to install n module dependencies

npm install n -g

Update the node version to the latest version of N latest and to the stable version of N stable

#Latest edition
n latest
#Stable version
n stable

关注我更多精彩