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).
答案 0 :(得分:0)
尽管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'
然后重新运行升级,它将成功。