最近,每当我运行任何 npm 脚本时,我都会收到以下警告:
npm WARN npm npm does not support Node.js v12.4.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 Supported releases of Node.js are the latest release of 6, 8, 9, 10, 11.
npm WARN npm You can find the latest version at https://nodejs.org/
它说我应该升级到更新版本,但 v12.4 是 最新版本。尽管脚本运行良好,但我认为无法保证,并且随时可能出现问题。
我也尝试过更新 npm
以防有更新版本使用 npm install npm -g
但收到错误:
npm ERR! path /usr/local/Cellar/node/12.4.0/lib/node_modules/npm
npm ERR! code EACCES
npm ERR! errno -13
npm ERR! syscall access
npm ERR! Error: EACCES: permission denied, access '/usr/local/Cellar/node/12.4.0/lib/node_modules/npm'
npm ERR! [Error: EACCES: permission denied, access '/usr/local/Cellar/node/12.4.0/lib/node_modules/npm'] {
npm ERR! stack: 'Error: EACCES: permission denied, access ' +
npm ERR! "'/usr/local/Cellar/node/12.4.0/lib/node_modules/npm'",
npm ERR! errno: -13,
npm ERR! code: 'EACCES',
npm ERR! syscall: 'access',
npm ERR! path: '/usr/local/Cellar/node/12.4.0/lib/node_modules/npm'
npm ERR! }
npm ERR!
npm ERR! The operation was rejected by your operating system.
npm ERR! It is likely you do not have the permissions to access this file as the current user
npm ERR!
npm ERR! If you believe this might be a permissions issue, please double-check the
npm ERR! permissions of the file and its containing directories, or try running
npm ERR! the command again as root/Administrator (though this is not recommended).
然后我看到 npm
的 Homebrew 版本无法使用 npm 本身更新,所以我尝试通过 Homebrew
使用 brew upgrade npm
进行更新,但出现了这个错误:
Error: npm 12.4.0 already installed
由于某种原因,Brew 混淆了 node
s 和 npm
s 版本。
我做错了什么,我该如何摆脱这个警告?
原文由 Can Poyrazoğlu 发布,翻译遵循 CC BY-SA 4.0 许可协议
好像你搞砸了
/usr/local
的权限。以下是解决方法:
/usr/local
权限:npm
缓存并卸载它:node
(与npm
)npm
:那应该带来
npm@6.9.2
。在使用 ---
brew
或npm
安装软件时,您应该避免使用sudo
--- ,这可能会导致此类问题。