NPM install -- save and -- save-Dev

Source: Internet
Author: User

When using NPM to install the module, the following four commands are usually used: 1. NPM install Module # Install the module in the project directory./node_modules 2. NPM install module-G # The Position of the installation module to the global disk depends on the NPM config prefix. 3. NPM install module -- save (-S) # Install the module to the project directory and write dependencies to the dependencies node of the package file. 4. NPM install module -- save-Dev (-d) # Install the module to the project directory and write dependencies to the devdependencies node of the package file Run the following command to compare the four commands: NPM install modulename command 1. Install the module to the node_modules directory of the project. 2. The module dependency is not written to the devdependencies or dependencies node. 3. When you run NPM install to initialize the project, the module will not be downloaded. NPM install-G modulename command 1. Install the module to the global directory and do not save the module package in the node_modules directory of the project. 2. The module dependency is not written to the devdependencies or dependencies node. 3. When you run NPM install to initialize the project, the module will not be downloaded. NPM install-save modulename command 1. Install the module to the node_modules directory of the project. 2. The module dependency is written to the dependencies node. 3. When you run NPM install to initialize the project, the module will be downloaded to the project directory. 4. When you run NPM install -- production or specify the node_env variable value as production, the module is automatically downloaded to the node_modules directory. NPM install-save-dev modulename command 1. Install the module to the node_modules directory of the project. 2. The module dependency is written to the devdependencies node. 3. When you run NPM install to initialize the project, the module will be downloaded to the project directory. 4. When you run NPM install -- production or specify the node_env variable value as production, the module will not be automatically downloaded to the node_modules directory. Summary: The modules under the devdependencies node are required during development, such as the gulp used in the project and the CSS and JS compression modules. These modules are not required after our project deployment, so we can install them in the form of-save-Dev. Modules such as express are essential for project operation and should be installed under the dependencies node. Therefore, we should use-save for installation.

NPM install -- save and -- save-Dev

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.