npm install locally


In the past when I installed packages using npm(>=1.0) they would be installed locally, but not anymore.

My setup:

  • First I use nvm to install node.js.
  • My operating System:
  • alfred@alfred-laptop:~/node/so/6513101$ cat /etc/lsb-release DISTRIB_ID=Ubuntu<br> DISTRIB_RELEASE=10.10 DISTRIB_CODENAME=maverick DISTRIB_DESCRIPTION="Ubuntu 10.10"
  • My node version:
  • alfred@alfred-laptop:~/node/so/6513101$ node -v v0.4.8
  • My npm version:
  • alfred@alfred-laptop:~/node/so/6513101$ npm -v 1.0.15

Installing random package

alfred@alfred-laptop:~/node/so/6513101$ npm install notifo
notifo@0.0.2 ../../../node_modules/notifo

In the past it would install into the same directory but it does not install in the same directory anymore. is my npm/node.js broken or am I missing something or does npm not anymore install local packages(inside same folder => ~/node/so/6513101/node_modules) which I thought was a cool feature because I could bundle all my dependencies so that other users did not have to install npm to use my code(I still believe users should install npm because it is a great product). The bundle command is gone so I can't use that? Could someone please explain to me what is going on?

Problem courtesy of: Alfred


npm walks up the folder tree until it finds a node_modules or a package.json and uses that as the root. What does npm root print out?

If you mkdir node_modules or create a package.json file, then it'll use the cwd.

EDIT: I won’t see updates you post here. For better results, just post everything in the github issue, and let’s do the support over there.

Solution courtesy of: isaacs

View additional discussion.