关于node.js:NPM-NODE-升级最新版

版本查看

$ npm -v
npm WARN npm npm does not support Node.js v14.8.0
npm WARN npm You should probably upgrade to a newer version of node as we
npm WARN npm can't make any promises that npm will work with this version.
npm WARN npm You can find the latest version at https://nodejs.org/
8.0.0

$ node -v
v14.8.0

NPM 更新

$ npm install -g npm
/usr/local/bin/npx -> /usr/local/lib/node_modules/npm/bin/npx-cli.js
/usr/local/bin/npm -> /usr/local/lib/node_modules/npm/bin/npm-cli.js
npm WARN notsup Unsupported engine for npm@8.0.0: wanted: {"node":"^12.13.0 || ^14.15.0 || >=16"} (current: {"node":"14.8.0","npm":"6.14.7"})
npm WARN notsup Not compatible with your version of node/npm: npm@8.0.0

NODE 更新

# 清理缓存
$ npm cache clean -f
npm WARN npm npm does not support Node.js v14.8.0
npm WARN npm You should probably upgrade to a newer version of node as we
npm WARN npm can't make any promises that npm will work with this version.
npm WARN npm You can find the latest version at https://nodejs.org/
npm WARN using --force Recommended protections disabled.

# 装置n模块
$ npm install -g n
npm WARN npm npm does not support Node.js v14.8.0
npm WARN npm You should probably upgrade to a newer version of node as we
npm WARN npm can't make any promises that npm will work with this version.
npm WARN npm You can find the latest version at https://nodejs.org/

added 1 package, and audited 2 packages in 6s

found 0 vulnerabilities

# 留神要加 sudo,否则会报权限问题
$ sudo n stable
Password:
  installing : node-v14.18.0
       mkdir : /usr/local/n/versions/node/14.18.0
       fetch : https://nodejs.org/dist/v14.18.0/node-v14.18.0-darwin-x64.tar.xz

Done

评论

发表回复

您的邮箱地址不会被公开。 必填项已用 * 标注

这个站点使用 Akismet 来减少垃圾评论。了解你的评论数据如何被处理