Reputation: 49
What is the difference between installing a package locally and globally using npm?
From my understanding:
Locally install: npm install <package>
Globally install: npm install <package> -g
Please let me know. If I could misunderstand anything here. Thanks!
Upvotes: 4
Views: 5093
Reputation: 1542
Global modules are mostly tools like gulp, yoman or any other module you use in your daily work.
Local modules are the dependencies of your project. You should never depend on a global module in your project. Even dependencies as gulp should be a local dependency in your dev-dependency section.
Upvotes: 0
Reputation: 2900
You are correct except for 1 point.
The local packages exposing CLI utilities can be accessed from the command line. Newer versions of NPM create this .bin/
directory inside the local node_modules/
.
Whenever you try to use a tool (let's take babel for example), if you use it from the command line and you have it installed in your project, npm will properly identify that package and run it's CLI for you.
Here's a useful article on the topic.
http://www.2ality.com/2016/01/locally-installed-npm-executables.html
Upvotes: 3