npm install failed with Error: EPERM: operation not permitted, unlink '\node_modules'

拥有回忆 提交于 2020-08-09 09:31:12

问题


I try to run "npm install" command in CMD ["node_modules" is inside C drive] but installation failing with below error.

OS :Windows 10.

Node JS version: 6.9.0.

Error: EPERM: operation not permitted, unlink.

Goal: To run AngularJs project.

CMD command

npm install -- no optional;

PS C:\Users\arunk\Work\Workspaces\workspace-2\brainbox-frontend-angular> npm install --no-optional

npm ERR! path C:\Users\arunk\Work\Workspaces\workspace-2\brainbox-frontend-angular\node_modules\.staging\typescript-5afdc8eb\lib\tsc.js
npm ERR! code EPERM
npm ERR! errno -4048
npm ERR! syscall unlink
npm ERR! Error: EPERM: operation not permitted, unlink 'C:\Users\arunk\Work\Workspaces\workspace-2\brainbox-frontend-angular\node_modules\.staging\typescript-5afdc8eb\lib\tsc.js'
npm ERR!  [Error: EPERM: operation not permitted, unlink 'C:\Users\arunk\Work\Workspaces\workspace-2\brainbox-frontend-angular\node_modules\.staging\typescript-5afdc8eb\lib\tsc.js']
{
npm ERR!   stack: 'Error: EPERM: operation not permitted, unlink ' +
npm ERR!     "'C:\\Users\\arunk\\Work\\Workspaces\\workspace-2\\brainbox-frontend-angular\\node_modules\\.staging\\typescript-5afdc8eb\\lib\\tsc.js'",
npm ERR!   errno: -4048,
npm ERR!   code: 'EPERM',
npm ERR!   syscall: 'unlink',
npm ERR!   path: 'C:\\Users\\arunk\\Work\\Workspaces\\workspace-2\\brainbox-frontend-angular\\node_modules\\.staging\\typescript-5afdc8eb\\lib\\tsc.js'
npm ERR! }
npm ERR!
npm ERR! The operation was rejected by your operating system.
npm ERR! It's possible that the file was already in use (by a text editor or antivirus),
npm ERR! or that you lack permissions to access it.
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 ERR! A complete log of this run can be found in:
npm ERR!     C:\Users\arunk\AppData\Roaming\npm-cache\_logs\2019-05-22T19_01_22_659Z-debug.log

回答1:


I had the same problem and tried a lot of different things. This solved my problem:

1 - Uninstall NodeJs
2 - Delete folders 'npm' and 'npm-cache' from AppData/Roaming
3 - Deactivate firewall and all antivirus (including Windows Defender)
4 - Reboot the system
5 - Open command prompt as administrator and execute 'npm install'



回答2:


Like you I have wasted much time trying to get 'npm install' to install Angular projects from its 'project.json' file and received similar error messages that are unhelpful; Recently I installed 'yarn' and this does a much better job of populating the 'node_modules' folder and it also generates more useful error and warning messages in the process.

Try the following steps:

  1. Install 'Yarn' - go to it's website and download the installer for your operating system.

  2. Got to your project directory (the one containing 'project.json')

  3. enter the command 'yarn' and wait. This will perform the same function as 'npm install', however it will generate fewer messages but the ones it does will be more pertinent.

I hope this helps.




回答3:


I was using yarn to install axios and got the same error, but I figured out that this error is not peculiar to axios since the same thing happens with all other packages.

Killing all running node process worked for me.




回答4:


Try clearing the cache

npm cache clean --force



来源:https://stackoverflow.com/questions/56263640/npm-install-failed-with-error-eperm-operation-not-permitted-unlink-node-mod

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!