【问题标题】:Node cannot upgrade on High Sierra节点无法在 High Sierra 上升级
【发布时间】:2019-06-14 22:17:16
【问题描述】:

Mac OS High Sierra 在这里。我正在尝试从node 10.4.0 -> 10.9.0+ 升级。我跑:

$ node -v
v10.4.0

然后:

$ sudo npm install -g n

我得到:

$ sudo npm install -g n
Unhandled rejection Error: EISDIR: illegal operation on a directory, open '/Users/myuser/.npm/_cacache/index-v5/b0/67'

npm ERR! cb() never called!

npm ERR! This is an error with npm itself. Please report this error at:
npm ERR!     <https://npm.community>

npm ERR! A complete log of this run can be found in:
npm ERR!     /Users/myuser/.npm/_logs/2019-06-12T19_41_01_814Z-debug.log

当我到达/Users/myuser/.npm/_logs/2019-06-12T19_41_01_814Z-debug.log 时,我看到一个空/空白文件。

发生了什么,解决方法是什么?


更新

这是我尝试清理缓存时得到的结果:

$ npm cache clean
npm ERR! As of npm@5, the npm cache self-heals from corruption issues and data extracted from the cache is guaranteed to be valid. If you want to make sure everything is consistent, use 'npm cache verify' instead. On the other hand, if you're debugging an issue with the installer, you can use `npm install --cache /tmp/empty-cache` to use a temporary cache instead of nuking the actual one.
npm ERR! 
npm ERR! If you're sure you want to delete the entire cache, rerun this command with --force.
$ npm cache clean --force
npm WARN using --force I sure hope you know what you are doing.
npm ERR! path /Users/myuser/.npm/_cacache/content-v2
npm ERR! code EACCES
npm ERR! errno -13
npm ERR! syscall rmdir
npm ERR! Error: EACCES: permission denied, rmdir '/Users/myuser/.npm/_cacache/content-v2'
npm ERR!  { [Error: EACCES: permission denied, rmdir '/Users/myuser/.npm/_cacache/content-v2']
npm ERR!   cause:
npm ERR!    { Error: EACCES: permission denied, rmdir '/Users/myuser/.npm/_cacache/content-v2'
npm ERR!      errno: -13,
npm ERR!      code: 'EACCES',
npm ERR!      syscall: 'rmdir',
npm ERR!      path: '/Users/myuser/.npm/_cacache/content-v2' },
npm ERR!   isOperational: true,
npm ERR!   stack:
npm ERR!    'Error: EACCES: permission denied, rmdir \'/Users/myuser/.npm/_cacache/content-v2\'',
npm ERR!   errno: -13,
npm ERR!   code: 'EACCES',
npm ERR!   syscall: 'rmdir',
npm ERR!   path: '/Users/myuser/.npm/_cacache/content-v2' }
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 cache clean 然后尝试重新安装吗?如果这不起作用,那么npm cache clean --force?
  • 感谢@AritraChakraborty (+1) 请在上面查看我的更新
  • 您的用户是否有权在您的机器上安装/升级?
  • 是的,这是我的个人笔记本电脑。我应该试试sudo npm cache clean --force 吗?这会做什么?我机器上的应用程序会开始崩溃吗?!
  • 用 sudo 运行它

标签: node.js macos npm


【解决方案1】:

虽然PR is currently underway 临时解决办法是:

以完全相同的方式修改两个以下文件:

  • /usr/local/lib/node_modules/npm/node_modules/chownr/chownr.js;和
  • /usr/local/lib/node_modules/npm/node_modules/tar/node_modules/chownr/chownr.js

通过更改来修改这些文件:

/* istanbul ignore next */
const LCHOWN = fs.lchown ? 'lchown' : 'chown'
/* istanbul ignore next */
const LCHOWNSYNC = fs.lchownSync ? 'lchownSync' : 'chownSync'

收件人:

/* istanbul ignore next */
const LCHOWN = 'chown'
/* istanbul ignore next */
const LCHOWNSYNC = 'chownSync'

然后重新运行升级,应该会成功。

【讨论】:

    猜你喜欢
    • 2018-03-28
    • 2021-07-05
    • 2018-05-25
    • 2019-05-15
    • 2021-08-28
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多