我已将 NPM 从 5.3.0 升级到 5.4.1,之后,命令 npm install 似乎只有在我删除 node_modules 后才有效。当我尝试重新运行安装时,收到以下错误消息。 (在那之后,如果我再次删除 node_modules,run install 命令会起作用 - 一次。)
PS C:\source\website> npm install
npm ERR! path C:\source\website\node_modules\fsevents\node_modules\aproba\package.jsonvet.Web
npm ERR! code EPERM
npm ERR! errno -4048
npm ERR! syscall unlink
npm ERR! Error: EPERM: operation not permitted, unlink 'C:\source\website\node_modules\fsevents\node_modules\aproba\package.json'
npm ERR! {
Error: EPERM: operation not permitted, unlink 'C:\source\website\node_modules\fsevents\node_modules\aproba\package.json'
npm ERR! stack: 'Error: EPERM: operation not permitted, unlink \'C:\source\website\node_modules\fsevents\node_modules\aproba\package.json\'',
npm ERR! errno: -4048,
npm ERR! code: 'EPERM',
npm ERR! syscall: 'unlink',
npm ERR! path:
'C:\source\website\node_modules\fsevents\node_modules\aproba\package.json' } npm ERR!
npm ERR! Please try running this command again as root/Administrator.
npm ERR! A complete log of this run can be found in:
npm ERR! C:\Users\butt\AppData\Roaming\npm-cache_logs\2017-09-13T16_42_26_030Z-debug.log
PS C:\source\website>
据我所知,我的设置没有任何其他变化。我的环境是 Windows 10 和 Node 8.2.1。该行为在多台计算机上似乎是一致的。
我注意到在重新运行安装期间,有很多等待时间,就像安装程序在下一阶段卡住一样。
added 995 packages in 29.671s
PS C:\source\website> npm install
[ ......] - postinstall: sill doSerial postinstall 686
我不知道如何处理这个问题。 fsevents 是罪魁祸首吗?我记得它产生了警告,但在早期版本中仍然可以正常转译。
有一个 related question关于这个主题,但恰恰涵盖了我的问题。我无法确定这只是同一问题的不同工作方式还是两个不同的问题。
最佳答案
这是许多人在 npm 5.4 中发现的一个常见问题,目前唯一的选择是将 npm 降级回 5.3
npm i -g npm@5.3.0
如需更多更新,请关注此线程。
https://github.com/npm/npm/issues/18380
P.S:您也可以在降级后尝试使用 npm cache clean --force
并尝试使用 npm i -g npm@5.4.1
或 npm install --no-optional
如果你真的需要 npm 5.4 来完成你的工作。
关于node.js - 升级到 NPM 5.4.1 后不删除 node_modules 就无法运行 "npm install",我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/46205937/