在升级到NPM 5.4.1版本后,无法运行“npm install”命令而不删除node_modules文件夹。

7
我将NPM从5.3.0升级到5.4.1后,发现只有在删除了node_modules之后才能运行npm install命令。当我尝试重新运行安装时,会出现以下错误消息。(之后,如果我再次删除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有责任吗?我记得它会产生警告,但在早期版本中仍然可以进行转换。

这个主题有一个相关问题,可以在这里找到,但没有准确涵盖到我的问题。我无法确定是同一问题的不同操作方式还是两个独立问题。

3个回答

4

许多人在使用npm 5.4时会遇到这个常见问题,目前唯一的解决方法是将npm降级回5.3。

npm i -g npm@5.3.0

欲获得更多更新,请关注此讨论串。

https://github.com/npm/npm/issues/18380

P.S.:如果您需要降级并尝试使用 npm i -g npm@5.4.1 或者 npm install --no-optional 安装 5.4 版本,您也可以尝试使用 npm cache clean --force 清除缓存以获得更好的使用体验。


0

不知道是什么原因导致了问题,但你可以尝试一些已经为其他人解决的解决方案:

  • 1

    npm cache clean

    npm install

  • 2

    npm i

  • 3

    通过右键单击选择“以管理员身份打开”来运行命令提示符,然后运行您的命令

希望这能帮到你。


0

我正在运行Win 10并遇到了同样的问题。解决方法是降级到5.3版本。我还注意到5.4.0在我们的构建服务器(TFS 2017)上可以正常工作。

npm install --global npm@5.3.0

完全没有帮助的一件事情是关于管理员模式的所有东西。我们花了几个小时使用管理员权限重新配置和重置构建管道。

有一个关键模块需要5.4.1版本,原因不重要。我们通过管道中的分步骤解决了这个问题 - 一个重用预构建版本,一个动态组装。

此外,我不会担心这个问题。在几天之内,肯定会有更新,问题将得到解决。在那之前 - 降级到5.3是我们使用的hack-around。


网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接