Local installation of a NPM package limits the impact of a package to a project folder. Unlike a global install that exposes potentially the package on the entire machine. The location of executables is not the same in both cases.
- Requirements :
- Install Node.js and npm
To install a package locally, run from a project folder :
npm install package-name
Unlike a globally installed package that can run potentially from anywhere, the executable of a locally installed package is located in a subfolder of the project :
See an example: run a local browser-sync on the command line
To install a package globally, run from anywhere :
npm install -g package-name
(or npm install --global package-name)
Unlike a locally installed package, the executable of a globally installed package is in a common folder.
For example, on Windows, the executable is in:
As long as you add this location to your
PATH environment variable, you can run this executable from anywhere.
See an example: run a global browser-sync on the command line