Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

npm installs all modules in /usr/local/lib/node_modules/

Tags:

node.js

npm

I have node.js 0.8.14 installed on Ubuntu 12.10. I created a directory in my home directory with a sub directory node_modules. I want to install some local node modules there but running
npm install myModule in this directory installs this module in /usr/local/lib/node_modules/ (same behavior as installing the module with the -g flag

There is no node path in .bashrc.

Any idea how I can install local node modules?

like image 334
vsdev Avatar asked Nov 18 '12 19:11

vsdev


2 Answers

After some further research I found the solution.

Running the command npm config ls revealed that the default config global=false (you see the default config with npm config ls -l) was overwritten by global=true in /home/vsdev/.npmrc and /usr/local/etc/npmrc.

Reverting this to global=false solved the issue.

like image 56
vsdev Avatar answered Sep 23 '22 12:09

vsdev


That is odd.

  • FYI you don't need to create the node_modules directory, npm will do that for you
  • npm normally just installs to the current directory. Even if the package you are installing is configured to prefer global installation, npm will install it locally unless you explicitly pass the -g parameter.
  • can you run the following shell commands and confirm npm is really the real npm?
    • which npm
    • alias | grep npm
like image 40
Peter Lyons Avatar answered Sep 22 '22 12:09

Peter Lyons