I get "Error: Cannot find module 'pool' " when running with sudo #17

metamindxx opened this Issue Nov 16, 2010 · 8 comments


None yet
3 participants

I got the proxy working with high numbered ports. When using port 80 I (think I) have to use sudo and I then get the error mentioned in the title.


indexzero commented Nov 16, 2010

Did you install pool via npm? Are you doing installations via npm with sudo? Not that you have to, but I know there are some issues around doing that.

I currently sudo my npm installations, so that might be the problem

npm. I installed npm using the "30 second method" (top one at https://gist.github.com/579814).

I just tried, and got (i'm a bit of a unix newbe):

:~/node-latest-install$ sudo npm install http-proxy

sudo: npm: command not found


:~/node-latest-install$ npm install http-proxy

works fine


indexzero commented Nov 16, 2010

Right. That means that npm isn't installed for the root user, so the packages aren't getting loaded from the correct paths when you run a script using http-proxy with sudo. I'm not sure the right approach here honestly.

Maybe try this:

  curl http://npmjs.org/install.sh | sudo sh

OK. That seems to have done the trick. I did get a bit of this sort of stuff though:

npm ERR! sudon't! Running npm as root is not recommended!

npm ERR! sudon't! Seriously, don't do this!

npm ERR! sudon't!


indexzero commented Nov 16, 2010

Yeah, it's true that it's not recommended, but that's just because isaacs hasn't gotten around to improving safe execution under sudo. He will eventually.

xrd commented Jan 13, 2011

I think a good way to do this is run node with an absolute path:

sudo which node ./connect -p 80

This allows you to use port 80, but does not require you to hardcode the path. And, it will use whatever version of node you are currently using under nvm.


xrd commented Jan 13, 2011

Hmm, did not come through in markdown. Here is a better version.

sudo which node app.js -p 80


indexzero commented Jan 13, 2011

Nice. I'll try that out. Although it shouldn't it never be run as root and really be an IP Tables setup?

This issue was closed.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment