Error: EPERM: operation not permitted, unlink 'D:\Sources\**\node_modules\fsevents\node_modules\abbrev\package.json'

前端 未结 30 2375
囚心锁ツ
囚心锁ツ 2020-12-05 04:00

I just updated npm to 5.4.0.
Now, Whenever I want install a npm package I get the following error:

D:\\Sources\\DownloadCms\\Md         


        
30条回答
  •  刺人心
    刺人心 (楼主)
    2020-12-05 04:35

    In my case, i was facing similar issue while running multiple instance of 'npm install' on VM used for build(Windows)

    Since it was a VM used only for build there was no other program locking the files. I tried disabling various antivirus settings which didn't worked. "npm cache clear" and "npm cache verify" worked but it was not a right solution for me as i cannot guess when somebody will trigger a build job from Jenkins for different release/environment leading to multiple instance of 'npm install' and hence i cannot add it to the build script nor i can go login to VM and clear/delete the cache folders manually every time.

    Finally, after some research, I ended up running "npm install" with separate cache path for each job using following command:

    npm install --cache path/to/some/folder
    

    Since, all the jobs running at the same time now had a separate cache path rather than the common global path (Users/AppData/Roaming/), this issue got fixed as the jobs were no more trying to lock and access the same file, from the common npm cache.

    Please note you can install a single package with a cache path as follows:

    npm install packageName --cache path/to/some/folder
    

    I was not able to find this way of giving a cache path in npm documentation but i gave it a try and it worked. I am using npm6 and looks like it works since npm5.

    [Refer: How to specify cache folder in npm5 on install command?

    This solution should work for other scenarios as well though may or may not be a good fit.

提交回复
热议问题