简体   繁体   English

为什么在Windows cmd中运行npm install会失败,但是从git bash或vs终端运行时却可以正常工作?

[英]why does npm install fail when run in windows cmd but works fine when run from git bash or vs terminal?

Tried running npm install -g @angular/cli 尝试运行npm install -g @ angular / cli

and got the below error consistently. 并始终出现以下错误。 Tried running it as administrator as well, yet no result. 尝试也以管理员身份运行它,但没有结果。

23286 error path C:\Users\XX\AppData\Roaming\npm\ng
23287 error code EPERM
23288 error errno -4048
23289 error syscall open
23290 error Error: EPERM: operation not permitted, open 'C:\Users\XX\AppData\Roaming\npm\ng'
23290 error  { Error: EPERM: operation not permitted, open 'C:\Users\XX\AppData\Roaming\npm\ng'
23290 error   cause:
23290 error    { Error: EPERM: operation not permitted, open 'C:\Users\XX\AppData\Roaming\npm\ng'
23290 error      errno: -4048,
23290 error      code: 'EPERM',
23290 error      syscall: 'open',
23290 error      path: 'C:\\Users\\XX\\AppData\\Roaming\\npm\\ng' },
23290 error   stack: 'Error: EPERM: operation not permitted, open \'C:\\Users\\XX\\AppData\\Roaming\\npm\\ng\'',
23290 error   errno: -4048,
23290 error   code: 'EPERM',
23290 error   syscall: 'open',
23290 error   path: 'C:\\Users\\XX\\AppData\\Roaming\\npm\\ng' }
23291 error Please try running this command again as root/Administrator.
23292 verbose exit [ -4048, true ]

I'm not 100% sure about Windows, but this could happen if you're using the project folder somewhere else, or in a different tool, or an Anti-virus locking the the installation. 我不确定Windows是否100%可靠,但是如果您在其他地方使用Project文件夹,或者在其他工具中使用该文件夹,或者使用防病毒功能锁定了安装,则可能会发生这种情况。

try running npm cache clean and then run npm install 尝试运行npm cache clean ,然后运行npm install

there may be some process locking the installation. 可能有一些过程锁定了安装。
But is this always going to be with trial and error. 但这总是会反复试验的。 How can i identify which process is blocking it and see if i can do something about 我如何确定哪个进程阻止了它,看看我是否可以做些什么

Use Process Explorer (simple exe, no setup required): with it, you can type Ctrl + F and search for " Roaming\\npm " for instance. 使用Process Explorer (简单exe,无需安装):使用它,您可以键入Ctrl + F并搜索“ Roaming\\npm ”。
Any process with an handle still open on that folder will be displayed. 将显示该文件夹上仍带有句柄的所有进程。

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 fgets 在 Windows 上从 bash 运行时导致 C 程序挂起,但在从 CMD 或 WSL 运行时正常工作 - fgets causes C program to hang when run from bash on Windows, but works correctly when run from CMD or WSL 运行Python代码时,Cmd和Git bash有不同的结果 - Cmd and Git bash have a different result when run a Python code Xcopy 命令在作为 Firebase 函数的预部署运行时抛出“参数数量无效”,但直接从终端运行时工作正常 - Xcopy command throws 'Invalid number of parameters' when run as predeploy of Firebase functions, but works fine when run directly from terminal 为什么从注册表打开/命令运行Powershell失败 - Why does powershell fail when run from registry open/command Windows CMD 脚本在 CMD 中手动输入时有效,但在作为 a.ZA28966BAC17B94EEF309 文件运行时失败 - Windows CMD Script Works When Manually Typed Out in CMD, but Fails When Run as a .CMD file schtasks命令在从CMD运行时有效,但不能从VBScript运行 - schtasks command works when run from CMD, but not from VBScript 从cmd.exe运行时,基于C的控制台应用程序崩溃了,在VS2008调试器中运行正常吗? - C-based console app crashes when run from cmd.exe, runs fine in VS2008 debugger? 为什么 Docker on Windows CMD 对于 bash 脚本失败? - Why does Docker on Windows CMD fail for bash script? “npm run”命令在 Windows 上失败 - “npm run” commands fail on Windows 为什么Windows的“运行:”与CMD行不同? - Why is Windows 'Run:' different from CMD line?
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM