npm - EPERM: operation not permitted on Windows
Javascriptnode.jsNpmBowerNpm InstallJavascript Problem Overview
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 ?
Javascript Solutions
Solution 1 - Javascript
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:
- Run cmd as administrator
- Run
npm config edit
(You will get notepad editor) - Change
prefix
variable toC:\Users\<User Name>\AppData\Roaming\npm
Then npm start
works in a normal console.
Solution 2 - Javascript
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.
Solution 3 - Javascript
Sometimes, all that's required is to stop the dev server before installing/updating packages.
Solution 4 - Javascript
I solved the problem by changing windows user access for the project folder:
Here is a screenshot: http://prntscr.com/djdn0g
Solution 5 - Javascript
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.
Solution 6 - Javascript
Restarting VsCode solved it for me!
Solution 7 - Javascript
I use Windows 10. I started the CMD as administrator, and it solved the problem.
Find CMD, right click, and click open as administrator.
Solution 8 - Javascript
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
Solution 9 - Javascript
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.
Solution 10 - Javascript
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.
Solution 11 - Javascript
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.
Solution 12 - Javascript
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
Solution 13 - Javascript
Just run cmd as admin. delete old node_modules folder and run npm install again.
Solution 14 - Javascript
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.
- Locate the file name
.npmrc
(it will be inC:\Users\<user name>\.npmrc
) - Open it and change the path of
prefix=
toprefix=C:\Users\<user name>\AppData\Roaming\npm
hope it will be helpful..
Solution 15 - Javascript
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.
Solution 16 - Javascript
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) ChangePrefix
variable toC:\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
Solution 17 - Javascript
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:
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
- Right-click on the project folder
- Go to
properties -> Security Tab
- Select
Users -> Edit
- In the
Permission for Users
section,Full control
->Give a check mark in Allow
->OK
- Wait for Windows security to apply the new security rules
- Click
OK
Visualization of the steps
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
Solution 18 - Javascript
Find this command npm cache clean
as a solution to those error in quick and simple way!
Solution 19 - Javascript
A reboot of my laptop and then
npm install
worked for me!
Solution 20 - Javascript
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).
Solution 21 - Javascript
I was running create-react-app server. Simply stopped the server and everything worked just fine.
Solution 22 - Javascript
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
Solution 23 - Javascript
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.
Solution 24 - Javascript
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.
Solution 25 - Javascript
I updated my node version to 8.9.4 and ran the necessary install command again from administrator command prompt. It worked for me!
Solution 26 - Javascript
Try npm i -g npm . NPM version 6.9 is work to me.
Solution 27 - Javascript
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.
Solution 28 - Javascript
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
Solution 29 - Javascript
The simpler way to solve this by entering the below command
npm config set cache C:\tmp\nodejs\npm-cache --global
Solution 30 - Javascript
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.
Solution 31 - Javascript
Running npm commands in Windows Powershell solved my issue.
Solution 32 - Javascript
Same to me, My solution was close Android studio, AVD Manager, Visual Studio and reinstall. I executed this command to update my expo cli:
npm install -g expo-cli
Solution 33 - Javascript
For me, It was an issue with the .npmrc file. Which is present in C:\Users\myname.npmrc
Somehow the content of .npmrc file got changed. I have changed the content by comparing with my colleagues laptop. So it solved.
For reference, I am adding the content of .npmrc file too
;;;;
;npm userconfig file
;this is a simple ini-formatted file
;lines that start with semi-colons are comments.
;read `npm help config` for help on the various options
;;;;
//registry.npmjs.org/:_authToken=95632bcf-3056-4538-b57d-38426736e3a0
scope=true
@true:registry=https://registry.npmjs.org/
;;;;
;all options with default values
;;;;
;access=null
;allow-same-version=false
;always-auth=false
;also=null
;audit=true
;audit-level=low
;auth-type=legacy
;before=null
;bin-links=true
;browser=null
;ca=null
;cafile=undefined
;cache=C:\Users\myname\AppData\Roaming\npm-cache
;cache-lock-stale=60000
;cache-lock-retries=10
;cache-lock-wait=10000
;cache-max=null
;cache-min=10
;cert=null
;cidr=null
;color=true
;depth=null
;description=true
;dev=false
;dry-run=false
;editor=notepad.exe
;engine-strict=false
;force=false
;fetch-retries=2
;fetch-retry-factor=10
;fetch-retry-mintimeout=10000
;fetch-retry-maxtimeout=60000
;git=git
;git-tag-version=true
;commit-hooks=true
;global=false
;globalconfig=C:\Users\myname\AppData\Roaming\npm\etc\npmrc
;global-style=false
;group=0
;ham-it-up=false
;heading=npm
;if-present=false
;ignore-prepublish=false
;ignore-scripts=false
;init-module=C:\Users\myname\.npm-init.js
;init-author-name=
;init-author-email=
;init-author-url=
;init-version=1.0.0
;init-license=ISC
;json=false
;key=null
;legacy-bundling=false
;link=false
;local-address=undefined
;loglevel=notice
;logs-max=10
;long=false
;maxsockets=50
;message=%s
;metrics-registry=null
;node-options=null
;node-version=10.15.2
;offline=false
;onload-script=null
;only=null
;optional=true
;otp=null
;package-lock=true
;package-lock-only=false
;parseable=false
;prefer-offline=false
;prefer-online=false
;prefix=C:\Program Files\nodejs
;preid=
;production=false
;progress=true
;proxy=null
;https-proxy=null
;noproxy=null
;user-agent=npm/{npm-version} node/{node-version} {platform} {arch}
;read-only=false
;rebuild-bundle=true
;registry=https://registry.npmjs.org/
;rollback=true
;save=true
;save-bundle=false
;save-dev=false
;save-exact=false
;save-optional=false
;save-prefix=^
;save-prod=false
;scope=
;script-shell=null
;scripts-prepend-node-path=warn-only
;searchopts=
;searchexclude=null
;searchlimit=20
;searchstaleness=900
;send-metrics=false
;shell=C:\windows\system32\cmd.exe
;shrinkwrap=true
;sign-git-commit=false
;sign-git-tag=false
;sso-poll-frequency=500
;sso-type=oauth
;strict-ssl=true
;tag=latest
;tag-version-prefix=v
;timing=false
;tmp=C:\Users\myname\AppData\Local\Temp
;unicode=false
;unsafe-perm=true
;update-notifier=true
;usage=false
;user=0
;userconfig=C:\Users\myname\.npmrc
;umask=0
;version=false
;versions=false
;viewer=browser
;_exit=true
;globalignorefile=C:\Users\myname\AppData\Roaming\npm\etc\npmignore
Solution 34 - Javascript
For those trying to update config
If having trouble updating your npm config, try instead running using the -g flag. This solved the issue on Win 10 for me after trying everything else.
npm config edit -g
I am able to update the config and changes are reflected everywhere. This may be due to running npm in an organizational scope.
Solution 35 - Javascript
npm install cross-env
Try this it worked for me.
Solution 36 - Javascript
After trying everything and nothing works. Moving my working project folder to diffrent destination worked for me.
Solution 37 - Javascript
Likely when you experience this issue, it is possible is a permission issue on your PC. Going to the PC properties and granting which ever account you use on your PC full control will solve it.
Again command /usr/local doesn't work on windows
Solution 38 - Javascript
If cleaning the cache(npm cache clean --force
) doesn't help you just delete
manually the folder C:\Users\%USER_NAME%\AppData\Roaming\npm-cacheand
and reinstall NodeJS
Solution 39 - Javascript
At least I just solved my problem in this way:
- Search
cmd
- Then run as administrator
- Then
npm i -g expo-cli
ornpm config set prefix /usr/local
I just solved my problem.
Solution 40 - Javascript
Install create-react-app
I did not install create-react app. so I just run npm install -g create-react-app
and the problèm was solved
Solution 41 - Javascript
Incredibly, this happens when you are building your project, e.g.
> ng build myprojet
...and you are stood up inside the dist/myprojet
, maybe withing the console. So you can easily close that console window or cd ..
to prevent this from happening.
Solution 42 - Javascript
I'd to update my npm using npm-windows-upgrade
Solution 43 - Javascript
In my case, it had to do with the directory webpack was targeting to build the files. Somehow, the directory couldn´t be deleted, even if I would try to do it manually by windows explorer. So, you can either force delete through CMD or, as strange as it may sound, I closed my web browser that I was using to load the webpack compiled files and managed to get the directory deleted. Afterwards, I ran webpack again and worked. Maybe that was causing the directory dele block.
Solution 44 - Javascript
I was having trouble with this issue as well. Try updating Node to the latest version and then try the operation again. It may help you.
Solution 45 - Javascript
For me the problem come from bash terminal. I change my terminal to powershell and it's ok.
Really easy to resolve
Solution 46 - Javascript
If using company LAN, disconnect try with other internet network.