I ran

npm config set prefix /usr/local 

After running that command, When trying to run any npm commands on Windows OS I keep getting the below.

Error: EPERM: operation not permitted, mkdir 'C:\Program Files (x86)\Git\local' at Error (native) 

Have deleted all files from

C:\Users\<your username>\.config\configstore\ 

It did not work.

Any suggestion ?

6

46 Answers

1 2

Running this command was my mistake.

npm config set prefix /usr/local

Path /usr/local is not for windows. This command changed the prefix variable at 'C:\Program Files (x86)\Git\local'

To access and make a change to this directory I need to run my cmd as administrator.

So I did:

  1. Run cmd as administrator
  2. Run npm config edit (You will get notepad editor)
  3. Change prefix variable to C:\Users\<User Name>\AppData\Roaming\npm

Then npm start works in a normal console.

3

This is occurring because windows is not giving permission to the user to create a folder inside system drive. To solve this:

Right Click

The Folder > Properties > Security Tab

Click on Edit to change Permissions > Select the user and give Full Control to that user.

6

Sometimes, all that's required is to stop the dev server before installing/updating packages.

2

I solved the problem by changing windows user access for the project folder:

Here is a screenshot:

enter image description here

1

Restarting VsCode solved it for me!

1

I recently had the same problem when I upgraded to the new version, the only solution was to do the downgraded

To uninstall:

npm uninstall npm -g 

Install the previous version:

npm install npm@5.3 -g 

Try update the version in another moment.

1

I use Windows 10. I started the CMD as administrator, and it solved the problem.

Find CMD, right click, and click open as administrator.

3

I had an outdated version of npm. I ran a series of commands to resolve this issue:

npm cache clean --force 

Then:

npm install -g npm@latest --force 

Then (once again):

npm cache clean --force 

And finally was able to run this (installing Angular project) without the errors I was seeing regarding EPERM:

ng new myProject 
1

In my case, I was facing this error because my directory and its file were opened in my editor (VS code) while I was running npm install. I solved the issue by closing my editor and running npm install through the command line.

I had the same problem, after updating npm. Solved it by re-installing latest npm again with:

npm i -g npm 

but this time with cmd running in administrating mode.

i did all this because i suspected there was an issue with the update, mostly some missing files.

I had the same problem when I tried to install the npm package AVA. The solution for me was to delete the node_modules folder and force-clean the npm cache:

rm -rf node_modules npm cache clean --force 

I could then install the npm package without a problem.

1

for me it was an issue of altering existing folders in node_module, so i nuked the whole folder and run npm install again. it works with no errors after that

0

Just run cmd as admin. delete old node_modules folder and run npm install again.

1

Happened to me since the folder/file was locked by another process. Used a tool (LockHunter) to terminate that process and it started working again (possible reason).

Simplest way

Hope I am not too late for this post but recently even I too got hit by this issue. And also I had no admin rights on my laptop.

Here is the simplest way I fixed the bug.

  1. Locate the file name .npmrc (it will be in C:\Users\<user name>\.npmrc)
  2. Open it and change the path of prefix= to prefix=C:\Users\<user name>\AppData\Roaming\npm

hope it will be helpful..

0

If you getting this error in an IDE's terminal/commands prompt, try delete node_modules, close IDE, and run the npm install command again. The time when IDE started but still not completed its analysis of node_modules tree is a tricky moment, when packages installation may fail because IDE still scanning node_modules contents.

This error is caused by different problems try the below one of them will work for you!

  • try to run npm as Administrator

  • Run cmd as administrator npm config edit (You will get notepad editor) Change Prefix variable to C:\Users\<User Name>\AppData\Roaming\npm

  • The errors went after I disabled my anti-virus (Avast)

  • Sometimes a simple cache clear like the below would fix it.

     npm cache clear 

The Problem I faced (In Windows Computer)

When I was trying to install a couple of npm packages I got the following error:

npm - EPERM: operation not permitted - while npm was trying to rename a file

Here's my debug snippet for reference, if you've faced the similar problem:

The Problem I faced

After carefully checking out the answers from other users, I have created a detailed answer for the community

My Solution for the problem

Follow the mentioned steps

  1. Right-click on the project folder
  2. Go to properties -> Security Tab
  3. Select Users -> Edit
  4. In the Permission for Users section, Full control -> Give a check mark in Allow -> OK
  5. Wait for Windows security to apply the new security rules
  6. Click OK

Visualization of the steps

Change Security rules

If you follow these steps and try to install npm packages again it will work properly.

Note: It's a best practice to close and open up the command line again to experience the changes

0

Find this command npm cache clean as a solution to those error in quick and simple way!

I updated my node version to 8.9.4 and ran the necessary install command again from administrator command prompt. It worked for me!

A reboot of my laptop and then

npm install

worked for me!

Try npm i -g npm . NPM version 6.9 is work to me.

Apparently anti-virus software can also cause this error. In my case I had Windows Security's Ransomware Protection protecting my user folders which caused this error.

Windows 10,

Running the IDE (in my case IntelliJ) in administrator mode and executing npm install does resolves the problem.

If no IDE then run CMD in administrator mode and try executing npm install

I was running create-react-app server. Simply stopped the server and everything worked just fine.

0

The simpler way to solve this by entering the below command

npm config set cache C:\tmp\nodejs\npm-cache --global 

Try installing it globally first, using the command {npm install -g create-react-app}

And then, you can create your app using the command, {npx create-react-app }

worked for me

Just stop react server and then install the package.

This issue occurs because when react is running (with yarn start or npm start), It is using some resources.

0

I had the same issue, as I was using my company LAN. And I just ran cmd.exe npm and I was able to execute my other commands without any error after that.

C:\Users\586656>cmd.exe npm Microsoft Windows [Version 10.0.14393] (c) 2016 Microsoft Corporation. All rights reserved. 

Just sharing this, as it may help other folks who try to do this in their office LAN. Thank you.

Try to install npm package by running CMD as Administrator. you can headover to broad discussion on this bug at npm install throwing error EPERM.

1 2