What is the difference between npm global installation and local installation? What?

  node.js, question

In addition to the calling method and installation location, I would also like to ask the following questions.

  • After the global installation, whether the local installation needs networking or not, repeat the previous process. Instead of copying directly from the global?
  • I saw that the installation of css-sprite took a long time to compile and install, and it would be a waste of time to do it again for local installation.

Global installation

Global installation-gIt is only necessary to install it once. Generally, like tools such as bower, I will install it globally. Generally, I will install it at/usr/localOr the directory where your node is installed.

Generally, package installed globally have command line requirements, such as bower mentioned earlier. You need to use bower in the command line.


None of the libraries in the project will be installed globally; when NPM is installed, it will be installed at./node_modulesInside, in short, the installation location is different.

All you need is these librariesrequire()It will work.

npm link

Npm link you can take a look at this.

First, npm link in a package folder will create a globally-installed symbolic link from prefix/package-name to the current folder (see npm-config(7) for the value of prefix).