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