0

I have installed nodejs and npm using repos in Ubuntu 12.10, and generally I install a module using

sudo npm install -g nodemodule

but when I try to do var mod = require("nodemodule") I receive an error I have to use require("/usr/lib/node_modules/nodemodule"), how canI fix this?

1 Answer 1

1

You probably need to set the NODE_PATH environment variabele:

export NODE_PATH=/usr/lib/node_modules/:$NODE_PATH

After that, try your Node script again. If it works, place the line above in your shells' startup file (usually ~/.bashrc) so it will always be set when you log in.

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

1 Comment

Thanks, it did not work when added to ~/.bashrc but it works with ~/.bash_profile

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.