npm警告:npm不支持Node.js v12.4.0

Can Poyrazoglu

每当我运行任何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无法使用npm本身来更新Homebrew版本,因此我尝试通过Homebrew使用进行更新,brew upgrade npm但出现了以下错误:

Error: npm 12.4.0 already installed

由于某种原因,Brew混合了nodes和npms版本。

我做错了什么,如何摆脱这个警告?

y

似乎您搞砸了中的权限/usr/local

解决方法如下:

  1. 修复/usr/local权限:

    sudo chown -R `id -un`:`id -gn` /usr/local
    
  2. 清理npm缓存并将其卸载:

    npm cache clean -f
    npm -g uninstall npm
    
  3. 重新安装node(带有npm

    brew reinstall node
    
  4. 升级npm

    npm -g i npm
    

那应该带来[email protected]

您应避免在使用sudo安装软件时使用,这可能会导致类似这样的问题。brewnpm

本文收集自互联网,转载请注明来源。

如有侵权,请联系 [email protected] 删除。

编辑于
0

我来说两句

0 条评论
登录 后参与评论

相关文章