Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

node npm local install override global install

Tags:

node.js

npm

If I have node modules installed locally (in the same folder as my node app) will they override global installations of the same modules?

like image 717
Dave Lee Avatar asked Sep 16 '11 19:09

Dave Lee


People also ask

Does npm install globally or locally?

Usually you install NPM modules globally if you want them included in your path to be ran from the command line. Since it is installed locally you will have to run it from the node_modules folder.

Does npm install overwrite node modules?

When npm install is run, it will examine the package. json file and attempt to install any dependencies listed that are not already installed to the node_modules directory. If there are no dependencies listed, it replaces the entire node_modules directory.


1 Answers

Yes. See the documentation here on module resolution. And, just to be clear, "override" here simply means that the local module is the one that will be resolved to. The global module will be left untouched, and node.js apps in other directories will still be able to use the global module.


Edit: it would probably also help to better understand how the global installs with npm work. More info on that is [here](https://nodejs.org/en/blog/npm/npm-1-0-global-vs-local-installation/).
like image 136
jmar777 Avatar answered Sep 29 '22 22:09

jmar777