#1.查看node版本
MacBook-Pro:~ syd$ node -v
v14.15.0
#2.清除缓存
sydMacBook-Pro:~ syd$ sudo npm cache clean -f
Password:
npm WARN using --force I sure hope you know what you are doing.
# 3.安装n工具,用来管理node.js版本的
sydMacBook-Pro:~ syd$ sudo npm install -g n
/usr/local/bin/n -> /usr/local/lib/node_modules/n/bin/n
+ n@8.0.0
updated 1 package in 4.816s
#4.安装最新版本的node.js
syddeMacBook-Pro:~ sydg$ sudo n stable
installing : node-v16.13.0
mkdir : /usr/local/n/versions/node/16.13.0
fetch : https://nodejs.org/dist/v16.13.0/node-v16.13.0-darwin-x64.tar.xz
installed : v16.13.0 (with npm 8.1.0)
#5.安装最新的npm
sydMacBook-Pro:~ syd$ sudo npm install npm@latest -g
Password:
removed 2 packages, changed 15 packages, and audited 219 packages in 11s
10 packages are looking for funding
run `npm fund` for details
3 moderate severity vulnerabilities
To address all issues, run:
npm audit fix
Run `npm audit` for details.
npm notice
npm notice New patch version of npm available! 8.1.0 -> 8.1.3
npm notice Changelog: https://github.com/npm/cli/releases/tag/v8.1.3
npm notice Run npm install -g npm@8.1.3 to update!
npm notice
syddeMacBook-Pro:~ syd$ node -v
v16.13.0
sydMacBook-Pro:~ syd$ npm -v