1

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.

2 Answers 2

7

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.

Sign up to request clarification or add additional context in comments.

5 Comments

As far as I know, this wont work because I don't have anything to use for 'proxy.company.com'.
Is there anything? there must be some way in which other things like your browser are communicating with the outside world(maybe in the settings of your browser?) Without a proxy you are just going to have to use that work around you found by mailing yourself the modules. You should install the modules locally in the directory of the project you are working in blog.nodejs.org/2011/03/23/npm-1-0-global-vs-local-installation
There may be something but I how would I find out by myself without asking someone here? Regarding the other method, that doesn't work. I think I made it clear in my post, but I have put them in node_modules, which is inside the local directory in which test_server.js .... Help :(
maybe you could use direct paths to the required modules. e.g. instead of: var http = require('http') use var http = require('my_project/module_folder/http') Though if it works it would be the wrong way of doing it.
I found out the proxy settings using this: superuser.com/questions/346372/… ... Although this didn't technically work for me, upon visiting the wpad.<suffix>/wpad.dat the web page revealed the proxy details to me. All good to go.
0

This worked for me post setting proxy -

Change the registry to the https version using the following command

npm config set registry https://registry.npmjs.org/

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.