Get Even More Visitors To Your Blog, Upgrade To A Business Listing >>

Node.js, NPM, proxy and node_modules

Node.js, NPM, proxy and node_modules

Problem

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

module.js:340
    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?

EDIT

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

Solution

This helped me http://jjasonclark.com/how-to-setup-node-behind-web-proxy

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

npm config set proxy http://proxy.company.com:8080
npm config set https-proxy http://proxy.company.com:8080

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

Solution courtesy of: Christopher Lawless

Discussion

View additional discussion.



This post first appeared on Node.js Recipes, please read the originial post: here

Share the post

Node.js, NPM, proxy and node_modules

×

Subscribe to Node.js Recipes

Get updates delivered right to your inbox!

Thank you for your subscription

×