NPM update:

1. Check the current version of NPMCopy the code
npm -v
Copy the code

2. The official website provides commandsCopy the code
npm install npm@latest -g
Copy the code

Installation will be automatically completed after running:

Update node:

1. Check the current version of NodeCopy the code
node -v
Copy the code

2. Clear the NPM cacheCopy the code
sudo npm cache clean -f
Copy the code

Blog.csdn.net/hengwen1991…

3. Install the N moduleCopy the code
sudo npm install -g n
Copy the code
4. Install the latest stable versionCopy the code
sudo n stable
Copy the code

You can also customize your own version:

Sudo n 8.1.2Copy the code
5. View the Node version and check whether the upgrade is successfulCopy the code
node -v
Copy the code

If this method does not work, you can only solve the problem by force (download the latest stable version from the official website and overwrite the installation…).

Check the path where Node is already installed before overwriting:

where node
Copy the code

nodejs.org/zh-cn/

Installation process: Next step… The next step.. The next step. Can be installed (pay attention to overwrite installation)