npm - EPERM: operation not permitted on Windows

2020-01-24 02:19发布

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 ?

27条回答
相关推荐>>
2楼-- · 2020-01-24 02:50

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.

查看更多
劫难
3楼-- · 2020-01-24 02:51

I solved the problem by changing windows user access for the older:

Here is a screenshot: http://prntscr.com/djdn0g

enter image description here

查看更多
做个烂人
4楼-- · 2020-01-24 02:51

Restarting VsCode solved it for me

查看更多
啃猪蹄的小仙女
5楼-- · 2020-01-24 02:53

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.

查看更多
我只想做你的唯一
6楼-- · 2020-01-24 02:53

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
查看更多
该账号已被封号
7楼-- · 2020-01-24 02:54

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.

查看更多
登录 后发表回答