【问题标题】:npm - EPERM: operation not permitted on Windowsnpm - EPERM:在 Windows 上不允许操作
【发布时间】:2016-04-08 15:26:01
【问题描述】:

我跑了

npm config set prefix /usr/local

运行该命令后, 当尝试在 Windows 操作系统上运行任何 npm 命令时,我不断收到以下信息。

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

已删除所有文件

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

没有用。

有什么建议吗?

【问题讨论】:

  • Running npm cache clean --force 为我解决了这个问题。
  • 运行 npm cache clean --force 两次对我有用。
  • 您是在cmd.exe“终端”(命令提示符)还是从GitBash 终端运行它的?对我来说,当我在 GitBash 中运行它时它失败了,但是当我在 cmd 中运行它时它运行良好。
  • 今天我在cmd.exe 中也获得了 EPERM。但是我在C:\Program Files\nodejs 中运行了以下命令,它似乎有效:npm cache clean --force &amp;&amp; npm install &lt;package-name&gt; --force --global。我还将C:\Program Files\nodejs\node_modules 添加到我的系统PATH 环境变量中。
  • 屏幕转储:i.imgur.com/VLFS7lG.png。但最好先尝试stackoverflow.com/a/44014485

标签: javascript node.js npm bower npm-install


【解决方案1】:

我也一样, 我的解决方案是关闭 Android Studio、AVD Manager、Visual Studio 并重新安装。 我执行了这个命令来更新我的 expo cli:

npm install -g expo-cli

【讨论】:

    【解决方案2】:

    对我来说,这是 .npmrc 文件的问题。存在于 C:\Users\myname.npmrc 不知何故 .npmrc 文件的内容发生了变化。我通过与同事的笔记本电脑进行比较来更改内容。于是就解决了。

    作为参考,我也在添加 .npmrc 文件的内容

     ;;;;
     ;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
    

    【讨论】:

      【解决方案3】:

      对于那些尝试更新配置的人

      如果在更新 npm 配置时遇到问题,请尝试使用 -g 标志 运行。在尝试了其他所有方法后,这为我解决了 Win 10 上的问题。

      npm config edit -g
      

      我能够更新配置并且更改会随处反映。这可能是由于在组织范围内运行 npm。

      【讨论】:

        【解决方案4】:

        npm 安装跨环境 试试这个它对我有用。

        【讨论】:

          【解决方案5】:

          尝试了一切,但没有任何效果。 将我的工作项目文件夹移动到不同的目的地对我有用。

          【讨论】:

            【解决方案6】:

            当您遇到此问题时,可能是您的 PC 存在权限问题。转到 PC 属性并授予您在 PC 上使用的任何帐户完全控制将解决它。

            再次命令 /usr/local 在 Windows 上不起作用

            【讨论】:

              【解决方案7】:

              如果清理缓存(npm cache clean --force)对您没有帮助,请删除 手动文件夹C:\Users\%USER_NAME%\AppData\Roaming\npm-cacheand 并重新安装NodeJS

              【讨论】:

                【解决方案8】:

                通过输入以下命令解决此问题的更简单方法

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

                【讨论】:

                  【解决方案9】:

                  至少我只是这样解决了我的问题:

                  1. 搜索cmd
                  2. 然后以管理员身份运行
                  3. 然后npm i -g expo-clinpm config set prefix /usr/local

                  我刚刚解决了我的问题。

                  【讨论】:

                    【解决方案10】:

                    安装 create-react-app

                    我没有安装 create-react 应用程序。所以我只运行npm install -g create-react-app,问题就解决了

                    【讨论】:

                      【解决方案11】:

                      令人难以置信的是,这发生在您构建项目时,例如

                      构建 myprojet

                      ...您在dist/myprojet 中站起来,也许是在控制台中。因此,您可以轻松关闭该控制台窗口或 cd .. 以防止这种情况发生。

                      【讨论】:

                        【解决方案12】:

                        我想使用 npm-windows-upgrade 更新我的 npm

                        【讨论】:

                          【解决方案13】:

                          就我而言,它与 webpack 构建文件的目标目录有关。不知何故,该目录无法删除,即使我会尝试通过 Windows 资源管理器手动删除。因此,您可以通过 CMD 强制删除,或者听起来很奇怪,我关闭了用于加载 webpack 编译文件的 Web 浏览器并设法删除了目录。之后,我再次运行 webpack 并开始工作。也许这导致了目录删除块。

                          【讨论】:

                            【解决方案14】:

                            只需重新安装 NodeJS 就可以了

                            【讨论】:

                              【解决方案15】:

                              如果使用公司局域网,请断开尝试与其他互联网网络。

                              【讨论】:

                              • 请先看清楚问题并理解问题所在,然后尝试用描述性和相关格式来回答您的答案如何以及为什么可以成为可能的解决方案。希望对您有所帮助!
                              猜你喜欢
                              • 2019-12-24
                              • 2019-08-22
                              • 2018-05-26
                              • 1970-01-01
                              • 1970-01-01
                              • 2021-01-01
                              • 1970-01-01
                              • 2019-09-10
                              • 1970-01-01
                              相关资源
                              最近更新 更多