Javascript npm - EPERM:Windows 上不允许操作
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/34600932/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
npm - EPERM: operation not permitted on Windows
提问by Lahar Shah
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.
运行该命令后,尝试在 Windows 操作系统上运行任何 npm 命令时,我不断收到以下信息。
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 ?
有什么建议吗?
采纳答案by Lahar Shah
Running this command was my mistake.
运行这个命令是我的错误。
npm config set prefix /usr/local
npm 配置设置前缀 /usr/local
Path /usr/local
is not for windows. This command changed the prefix variable at 'C:\Program Files (x86)\Git\local'
路径/usr/local
不适用于 Windows。此命令更改了前缀变量'C:\Program Files (x86)\Git\local'
To access and make a change to this directory I need to run my cmd as administrator.
要访问并更改此目录,我需要以管理员身份运行我的 cmd。
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
- 以管理员身份运行cmd
- 运行
npm config edit
(您将获得记事本编辑器) - 将
prefix
变量更改为C:\Users\<User Name>\AppData\Roaming\npm
Then npm start
works in a normal console.
然后npm start
在普通控制台中工作。
回答by RatneZ
This is occurring because windows is not giving permission to the user to create a folder inside system drive. To solve this:
发生这种情况是因为 Windows 没有授予用户在系统驱动器内创建文件夹的权限。要解决这个问题:
Right Click
右键点击
The Folder > Properties> SecurityTab
文件夹 >属性>安全选项卡
Click on Editto change Permissions > Select the user and give Full Controlto that user.
单击编辑以更改权限 > 选择用户并将完全控制权授予该用户。
回答by lito
I solved the problem by changing windows user access for the older:
我通过更改较旧的 Windows 用户访问权限解决了这个问题:
Here is a screenshot: http://prntscr.com/djdn0g
这是截图:http: //prntscr.com/djdn0g
回答by Leonardo Oliveira
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 [email protected] -g
Try update the version in another moment.
稍后尝试更新版本。
回答by Ezra Obiwale
Sometimes, all that's required is to stop the dev server before installing/updating packages.
有时,所需要做的就是在安装/更新软件包之前停止开发服务器。
回答by Shashank Rawat
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.
就我而言,我遇到了这个错误,因为我的目录及其文件是在我运行时在我的编辑器(VS 代码)中打开的npm install
。我通过关闭编辑器并运行npm install
命令行解决了这个问题。
回答by Salimd83
I had the same problem, after updating npm. Solved it by re-installing latest npm again with:
更新 npm 后,我遇到了同样的问题。通过重新安装最新的 npm 解决了这个问题:
npm i -g npm
but this time with cmd running in administrating mode.
但这次 cmd 在管理模式下运行。
i did all this because i suspected there was an issue with the update, mostly some missing files.
我这样做是因为我怀疑更新存在问题,主要是一些丢失的文件。
回答by DIANGELISJ
I use Windows 10. I started the CMD as administrator, and it solved the problem.
我使用的是 Windows 10。我以管理员身份启动了 CMD,它解决了问题。
Find CMD, right click, and click open as administrator.
找到CMD,右击,点击以管理员身份打开。
回答by Sonic Soul
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
对我来说,这是更改 node_module 中现有文件夹的问题,所以我取消了整个文件夹并再次运行 npm install。在那之后它没有错误
回答by LatentDenis
I had an outdated version of npm
. I ran a series of commands to resolve this issue:
我有一个过时的版本npm
。我运行了一系列命令来解决这个问题:
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
:
最后能够运行这个(安装 Angular 项目)而没有我看到的错误EPERM
:
ng new myProject