mac 终端启动后提示 ERROR: npm is known not to run on Node.js v0.8.28
微wx笑 2020-06-23【操作系统】 8 0关键字: Mac 终端 npm Node.js
ERROR: npm is known not to run on Node.js v0.8.28You'll need to upgrade to a newer version in order to use thisversion of npm. Supported versions are 4, 6,
ERROR: npm is known not to run on Node.js v0.8.28
You'll need to upgrade to a newer version in order to use this
version of npm. Supported versions are 4, 6, 7, 8, 9. You can find the
latest version at https://nodejs.org/
nvm is not compatible with the npm config "prefix" option: currently set to ""
Run `npm config delete prefix` or `nvm use --delete-prefix v0.8.28 --silent` to unset it.
按照提示,执行`nvm use --delete-prefix v0.8.28 --silent` 输出
ERROR: npm is known not to run on Node.js v0.8.28
You'll need to upgrade to a newer version in order to use this
version of npm. Supported versions are 4, 6, 7, 8, 9. You can find the
latest version at https://nodejs.org/
ERROR: npm is known not to run on Node.js v0.8.28
You'll need to upgrade to a newer version in order to use this
version of npm. Supported versions are 4, 6, 7, 8, 9. You can find the
latest version at
https://nodejs.org/意思是需要更新 Node.js 的版本。
执行`npm config delete prefix`,输出:
ERROR: npm is known not to run on Node.js v0.8.28
You'll need to upgrade to a newer version in order to use this
version of npm. Supported versions are 4, 6, 7, 8, 9. You can find the
latest version at https://nodejs.org/
都是 Node.js 的版本太低了。
执行`node -v`输出的版本是:v0.8.28
安装一个新版本
$ nvm install 4 Downloading and installing node v4.9.1... Downloading https://nodejs.org/dist/v4.9.1/node-v4.9.1-darwin-x64.tar.xz... ######################################################################## 100.0% Computing checksum with shasum -a 256 Checksums matched! Now using node v4.9.1 (npm v2.15.11)
查看已经安装的版本
$ nvm list v0.8.28 v4.9.1 -> system default -> v0.8.28 node -> stable (-> v4.9.1) (default) stable -> 4.9 (-> v4.9.1) (default) iojs -> N/A (default) lts/* -> lts/erbium (-> N/A) lts/argon -> v4.9.1 lts/boron -> v6.17.1 (-> N/A) lts/carbon -> v8.17.0 (-> N/A) lts/dubnium -> v10.21.0 (-> N/A) lts/erbium -> v12.18.1 (-> N/A)
退出终端,重新打开,发现还是一样的错误,安装的新的版本并没有用。
修改默认版本
$ nvm alias default v4.9.1 default -> v4.9.1
修改之后发现默认的版本变为“v4.9.1”了
$ nvm list v0.8.28 -> v4.9.1 system default -> v4.9.1 node -> stable (-> v4.9.1) (default) stable -> 4.9 (-> v4.9.1) (default) iojs -> N/A (default) lts/* -> lts/erbium (-> N/A) lts/argon -> v4.9.1 lts/boron -> v6.17.1 (-> N/A) lts/carbon -> v8.17.0 (-> N/A) lts/dubnium -> v10.21.0 (-> N/A) lts/erbium -> v12.18.1 (-> N/A)
退出终端,重新打开,问题解决了。
本文由 微wx笑 创作,采用 署名-非商业性使用-相同方式共享 4.0 许可协议,转载请附上原文出处链接及本声明。
原文链接:https://www.ivu4e.cn/blog/system/2020-06-23/486.html