What does the -g flag do in the npm install -g <something> command?

I follow examples using the -g flag when using npm install , but I cannot figure out through the help system what the -g flag does.

+43
Oct 31 '12 at 21:18
source share
3 answers

-g tells npm install the named module so that it is globally accessible.

But it’s important to understand that -g usually used only for packages that provide command line utilities so that their executable components are available on the PATH system.

If you have several programs that require the same package, each program must install the package locally. If you really want to share the installed package by installing it worldwide, you should also use the npm link .

See the documentation for globally installed packages here .

+44
Oct 31 '12 at 9:19
source share

If you run npm help install , you will see that:

  o npm install (in package directory, no arguments): Install the dependencies in the local node_modules folder. In global mode (ie, with -g or --global appended to the com- mand), it installs the current package context (ie, the current working directory) as a global package. 
+14
Oct 31 '12 at 9:23
source share

Take the express module as an example. If it was previously installed with the -g option, you can write express anywhere to create a skeletal application.

+2
Oct 31 '12 at 21:24
source share



All Articles