Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

npm install locally

Tags:

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 [email protected] ../../../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?

like image 928
Alfred Avatar asked Jun 29 '11 00:06

Alfred


People also ask

Can I install npm locally?

You can install a package locally if you want to depend on the package from your own module, using something like Node. js require . This is npm install 's default behavior.

Does npm install locally or globally?

local packages are installed in the directory where you run npm install <package-name> , and they are put in the node_modules folder under this directory. global packages are all put in a single place in your system (exactly where depends on your setup), regardless of where you run npm install -g <package-name>

What is the npm syntax to install packages locally?

Installing a package with dist-tags To override this behavior, use the command below (where tag is the package's tag like beta , latest , etc.). npm install <package_name>@<tag>. To install a specific version of the ExpressJS library, type: npm install express@beta.


1 Answers

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.

like image 162
isaacs Avatar answered Nov 17 '22 09:11

isaacs