Home > Web Front-end > JS Tutorial > body text

The difference between nodejs npm install global installation and local installation_node.js

WBOY
Release: 2016-05-16 16:46:09
Original
1589 people have browsed it

npm package installation is divided into two types: local installation (local) and global installation (global). Judging from the command line, the difference is only whether there is -g, such as:

Copy code The code is as follows:

npm install grunt # Local installation
npm install -g grunt-cli # Global installation


Explained below.

1. When npm install xxx -g, the module will be downloaded and installed into the [global directory].

[Global directory] Set via npm config set prefix "directory path".

Get the currently set directory through npm config get prefix.

2. npm install xxx downloads the module to the directory where the current command line is located.

For example:

Copy code The code is as follows:
c:123>npm install xxx

will be installed to
Copy the code The code is as follows:
c:123node_modulesxxx

This method is obviously not good, so the global installation method is generally used to install it in a unified directory, which is convenient for management, has a clear structure, and can be reused.

Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template