As part of working with AngularJS, I tried to install Karma test runner by using npm on one of our new Build Slaves. I got this error while executing the installation.
$ npm install karma
npm http 200 http://registry.npmjs.org/abbrev
> phantomjs@1.9.7-6 install /usr/lib/node_modules/karma-phantomjs-launcher/node_modules/phantomjs
> node install.js
Downloading http://cdn.bitbucket.org/ariya/phantomjs/downloads/phantomjs-1.9.7-linux-x86_64.tar.bz2
Saving to /usr/lib/node_modules/karma-phantomjs-launcher/node_modules/phantomjs/phantomjs/phantomjs-1.9.7-linux-x86_64.tar.bz2
Using proxy http://company-proxy.com:8080/
Receiving...
Error requesting archive.
Status: 403
Request options: {
"protocol": "http:",
"slashes": true,
"auth": null,
"host": "company-proxy.com:8080",
"port": "8080",
"hostname": "company-proxy.com",
"hash": null,
"search": null,
"query": null,
"pathname": "/",
"path": "http://cdn.bitbucket.org/ariya/phantomjs/downloads/phantomjs-1.9.7-linux-x86_64.tar.bz2",
"href": "http://company-proxy.com:8080/",
"headers": {
"Host": "cdn.bitbucket.org",
"User-Agent": "curl/7.21.4 (universal-apple-darwin11.0) libcurl/7.21.4 OpenSSL/0.9.8r zlib/1.2.5"
}
}
Response headers: {
"cache-control": "no-cache",
"pragma": "no-cache",
"content-type": "text/html; charset=utf-8",
"proxy-connection": "Keep-Alive",
"connection": "Keep-Alive",
"content-length": "606"
}
Make sure your network and proxy settings are correct.
npm ERR! phantomjs@1.9.7-6 install: `node install.js`
npm ERR! Exit status 1
Solution: Turns out that I need to set the proxy for npm:
$ npm config set proxy "http://company-proxy.com:8080"
Then I hit another problem, where the output has this error
return code 407: Unauthorized; which means we need to add credential into the proxy config:$ npm config set proxy "http://username:password@company-proxy.com:8080"That's it. Installation is successful!
Side notes:
Sometimes, you might need to set the registry and set https-proxy:npm config set registry http://registry.npmjs.org/ npm config set https-proxy https://username:password@proxy.company.com:8080

Thanks for your post. It's very helpful post for us. You can also visit residential proxy for more Victor Steel related information. I would like to thanks for sharing this article here.
ReplyDeleteThis is a useful troubleshooting example for anyone working with AngularJS and Karma, especially because the installation issue was not caused by Karma itself but by the network proxy configuration on the build slave. The progression from the initial 403 error to the authenticated proxy requirement makes the problem and its resolution easy to follow.
ReplyDeleteThe explanation of configuring npm with a proxy is particularly practical for developers working in corporate environments where external package downloads have to pass through a proxy. This kind of setup is a useful part of an Angular Online Course when working with real development and build environments.
The second error, 407 Unauthorized, is also an important detail because it shows the difference between reaching a proxy and actually authenticating with it. Understanding npm configuration, package installation, and JavaScript tooling fits naturally with a JavaScript Online Course.