【问题标题】:Can't delete npm proxy无法删除 npm 代理
【发布时间】:2015-02-07 22:39:57
【问题描述】:

在工作中我有一个代理并在 npm 中设置它

 npm config set proxy http://theproxy:8080
 npm config set https-proxy https://theproxy:8080

失业了,我没有代理,需要在 npm 中删除它。

我试过了

 npm config rm proxy
 npm config rm https-proxy

 npm config delete proxy
 npm config delete https-proxy

但是当我使用

 npm config get proxy
 npm config get https-proxy

代理仍然存在

如何在 npm 中删除代理

【问题讨论】:

    标签: proxy npm


    【解决方案1】:

    下面的事情对我有用,请确保在删除配置条目之前未设置环境变量 HTTP_PROXY

    取消设置 HTTP_PROXY= 非常重要

    set HTTP_PROXY=
    npm config rm proxy
    npm config rm https-proxy
    npm config rm http-proxy
    

    【讨论】:

      【解决方案2】:

      对我来说效果很好..

      saidas-mbp:trunk saidababuchanda$ npm config set proxy https://www.google.com
      saidas-mbp:trunk saidababuchanda$ npm config get proxy 
      https://www.google.com
      saidas-mbp:trunk saidababuchanda$ npm config delete proxy 
      saidas-mbp:trunk saidababuchanda$ 
      saidas-mbp:trunk saidababuchanda$ npm config get proxy 
      null
      saidas-mbp:trunk saidababuchanda$ npm -v
      1.4.14
      saidas-mbp:trunk saidababuchanda$ 
      

      请查看你的 npm 版本

      【讨论】:

      • 如果我这样做npm config ls -l ,我会得到包括proxy = "proxy.theproxy.co.uk:8080" 在内的所有设置的列表。如果我做npm config set proxy https://www.google.com 然后npm config ls -l google.com 被设置为代理但我仍然有; proxy = "proxy.theproxy.co.uk:8080" (overridden) 。我有版本 1.4.14。删除 npm 安装是否是个好主意,这会有所帮助吗?
      【解决方案3】:

      试试这个

      npm 配置删除代理
      npm config 删除代理 -g
      npm 配置删除 https-proxy
      npm config 删除 https-proxy -g

      【讨论】:

        【解决方案4】:

        我怀疑,它是在你的 npmrc 文件中设置的,你能检查下面的文件吗?看看这个值是否设置在某个地方。

        npmrc 文件

        四个相关文件是: 每个项目的配置文件(/path/to/my/project/.npmrc) 每个用户的配置文件 (~/.npmrc) 全局配置文件 ($PREFIX/npmrc) npm 内置配置文件 (/path/to/npm/npmrc)

        【讨论】:

          【解决方案5】:
          npm config rm proxy
          npm config rm https-proxy
          npm config rm http-proxy
          

          【讨论】:

            【解决方案6】:

            我认为您的问题是您需要全局删除它。试试:

            npm config rm proxy -g
            npm config rm https-proxy -g
            

            【讨论】:

              【解决方案7】:

              三步解决方案。

              对我有用的是将proxy 设置为空字符串/ url,然后我使用npm config delete 删除https-proxy 设置。

              所以我运行了以下命令:

              npm config set proxy
              npm config delete https-proxy -g
              

              此外,您可以运行npm config list 来验证这些值确实已被删除。

              现在最后一件事,您需要运行以下命令:

              npm config edit

              将在您的默认文本编辑器中打开一个文件,在该文件中删除您添加的所有代理配置。

              【讨论】:

                【解决方案8】:

                我尝试了这个帖子中的所有解决方案,但都没有奏效。问题是代理设置在我的“C:\Users\YOURNAME.npmrc”文件中被注释掉了。取消注释它对我有用。

                proxy=null

                https-proxy=null

                【讨论】:

                  【解决方案9】:

                  在我的情况下,问题是在我位于包含 .npmrc 文件的特定文件夹项目中时尝试删除代理。 在文件里面有这个特定文件夹的代理定义。 所以我把里面的代理定义去掉了。

                  【讨论】:

                    猜你喜欢
                    • 1970-01-01
                    • 1970-01-01
                    • 1970-01-01
                    • 2019-05-01
                    • 2015-03-11
                    • 1970-01-01
                    • 1970-01-01
                    • 2020-04-27
                    • 2018-04-12
                    相关资源
                    最近更新 更多