Friday, February 26, 2016

Using NPM behind a company proxy

Yesterday I was giving training about Team Foundation Server when I wanted to demonstrate the tfs-cli tool. However when I tried to download the tool using npm install -g tfx-cli it failed. A company proxy was preventing npm to be able to connect to the outside world.

To fix this, you have to update the npm configuration file and specify the the proxy setting. Open a command prompt and run the following command to do this:

npm config set proxy

We also noticed that the first time we did this it didn’t work because the user wasn’t authenticated yet at the proxy level. However after opening up a browser and surfing to a site outside the company network the user was authenticated to the proxy and we were able to call npm.

1 comment:

Kristof Mattei said...

3 things here:

- Be careful, there might be an expiration on your company proxy credentials. This might give issues in the future if you want to install a new package (old ones are in the cache)
- Was the proxy configured in Internet Explorer?
- Is it possible to run the build as a user from the domain, and thus avoiding the first issue?