Nodejs npm install global installation and local Installation

Source: Internet
Author: User

Npm package installation can be divided into local installation and global installation. from the command line, the difference is-g. For example:
Copy codeThe Code is as follows:
Npm install grunt # local Installation
Npm install-g grunt-cli # global installation

The following are explanations.

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

[Global Directory] is set through npm config set prefix "directory path.

Use npm config get prefix to obtain the directory currently set.

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

For example:
Copy codeThe Code is as follows: c :\123> npm install xxx
Will be installed
Copy codeThe Code is as follows: c: \ 123 \ node_modules \ xxx

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

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.