Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

npm ERR! Error: EPERM: operation not permitted, rename

People also ask

How do I fix npm error Eperm Operation not permitted?

I fixed this error in Windows 10 by using the command you mentioned npm config get prefix to find the folder, then going up a folder, right clicking npm => properties => security tab => select a user => edit => change anything (even to just undo it. Anything to make the apply button not greyed out => hit apply.


In my situation this helped:

Before proceeding to execute these commands close all VS Code instances.

  1. clean cache with

     npm cache clean --force
    
  2. install the latest version of npm globally as admin:

     npm install -g npm@latest --force
    
  3. clean cache with

     npm cache clean --force
    
  4. Try to install your component once again.

I hope this fix your issue. If not, you may temporarily disable your antivirus program and try again.


I got it working when tried npm install with a force option to fetch remote resources even if a local copy exists on disk. Try running

npm install --force

Updated For some of my colleagues this solution was not working. But we tried using yarn instead of npm. It works (faster as well) without any issues all the time

yarn install [package-name]

Not package.json, but for whatever reason, my node_modules/ had become read-only. Resetting that fixed this.


For me i just closed the Code editor (VS Code) and then run the same command. And that solves the issue for me.


If you want to avoid the --force option (which is always a better approach), I suggest making sure that you have stopped running the project, as this is usually the main reason for locking the files in almost 90% of the cases I have seen

I suggest the following steps in this order:

1- In Angular stopping ng s and in React stopping npm start usually solves this issue because usually this error happens if a development server is running the project as it locks some files & then npm can't update them thus throwing this error

2- If the above doesn't work, then try closing the code editor that has the workspace opened in it (maybe it was locking some files or something)

So try closing the code editor & running:

npm install

3- If still it doesn't work, then maybe you can try the --force option

npm install --force

I was getting that same error and according to https://github.com/Medium/phantomjs/issues/19 it could be caused by your antivirus software. I disabled mine for the duration of the install and executed "npm install" on cmd as admin and it worked. Hope this helps.


As Martin Kearn pointed out in a comment, closing Visual Studio resolved these npm permission issues for me. Evidently VS sometimes locks files in node_modules.