Node.js, NPM, proxy and node_modules


I am trying to install node packages but my network won't let me connect. I get the standard,

npm ERR! network getaddrinfo ENOTFOUND

I understand that this is because I am on a corporate network. However, I'm not very familiar with proxies and as far as I am aware, I don't have access to one so I'm not sure how I can progress with NPM. Any helpful and related thoughts about this are warmly received!

As a work around, using my other machine, I have emailed myself with the node modules I require. These node modules were installed using NPM while not on the corporate network.

However, despite the fact that I have put the modules in node_modules/ alongside my test_server.js file, I still receive,

C:\Users\JT15900\Documents\nodeServer>node test_server.js

    throw err;
Error: Cannot find module 'knex' ... etc.

To be really clear, test_server.js sits alongside node_modules/ in the same directory. Inside node_modules/ I have put the various module folders like 'express' and 'knex', etc.

Why is my node script unable to find these modules and how to I correct it?


I used a post over at superuser to help discover my proxy settings. I then configured Node NPM proxy settings as outlined elsewhere and presented in the solution.

Problem courtesy of: jtromans


This helped me

if the corporate network has a proxy you can set it in npm using these commands

npm config set proxy
npm config set https-proxy

Apologies if you already tried that or it doesn't work.

Solution courtesy of: Christopher Lawless


There is currently no discussion for this recipe.

This recipe can be found in it's original form on Stack Over Flow.