Steve P
Steve P

Reputation: 19377

phantomjs npm install fails behind proxy

Trying to install PhantomJS via an npm wrapper while behind the corporate proxy. I had already set the http_proxy and https_proxy environment variables so that npm itself would be able to communicate with the registry:

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

But when it came to the node install.js stage of phantomjs, I got a Protocol not supported error:

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

Upvotes: 2

Views: 2387

Answers (2)

Fortune
Fortune

Reputation: 1595

This is what worked for me.

  1. Open the terminal as an administrator
  2. Navigate to your project folder and enter the following commands
  3. sudo npm config set proxy http://proxy_host:port -g then
  4. sudo npm config set https-proxy http://proxy_host:port -g

Hope this works for you. Good luck.

Upvotes: 0

Steve P
Steve P

Reputation: 19377

The problem was that the phantomjs npm wrapper code assumes that the proxy info is a complete url, not just a hostname. This resolves the issue:

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

npm, git, etc work fine with either format, but for this particular package it needs HTTP_PROXY to have a full URL.

UPDATE: this related issue has been resolved and now it can use the same configuration system as npm itself (e.g. if you used npm config command) rather than relying on environment variable.

Upvotes: 1

Related Questions