簡體   English   中英

phantomjs npm安裝在代理后面失敗

[英]phantomjs npm install fails behind proxy

在公司代理后面嘗試通過npm包裝器安裝PhantomJS 我已經設置了http_proxy和https_proxy環境變量,以便npm本身能夠與注冊表進行通信:

export http_proxy=my-company-proxy.com:80
export https_proxy=my-company-proxy.com:80

但是當涉及到phantomjs的節點install.js階段時,出現了“協議不支持”錯誤:

http.js:1711
    throw new Error('Protocol:' + options.protocol + ' not supported.');
      ^
Error: Protocol:my-company-proxy.com: not supported.

問題在於phantomjs npm包裝器代碼假定代理信息是完整的url,而不僅僅是主機名。 這樣可以解決問題:

export http_proxy=http://my-company-proxy.com:80
export https_proxy=http://my-company-proxy.com:80

npm,git等在任何一種格式下都可以正常工作,但是對於此特定程序包,它需要HTTP_PROXY才能具有完整的URL。

更新: 此相關問題已解決,現在它可以使用與npm本身相同的配置系統(例如,如果使用npm config命令),而不是依賴於環境變量。

這對我有用。

  1. 以管理員身份打開終端
  2. 導航到您的項目文件夾,然后輸入以下命令
  3. sudo npm config set proxy http://proxy_host:port -g然后
  4. sudo npm config set https-proxy http://proxy_host:port -g

希望這對您有用。 祝好運。

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM