NPM install --save, --save-dev, -g difference

dependencies and devDependencies difference under package.json file

devDependencies: development environment for
dependencies: for online environments

Key
dependencies dependent packages can be used not only online environment, the development environment can be used, vice versa

Note that
by default, run npm in which folder, create a folder on npm node_modules in the current directory

NPM install moduleName --save

  • The project module dependencies written to the node package.json
  • Installing the module into the current folder node_modules
  • When you run npm install, the module will be downloaded to the current directory node_modules

NPM install moduleName --save-dev

  • The project module is written to the node package.json of devDependencies
  • Installing the module into the current folder node_modules
  • When you run npm install, the module will be downloaded to the current directory node_modules

NPM install moduleName -g

  • Install the module to a global, not installed in your project directory node_modules
  • The module does not write information to or dependencies node devDependencies
  • When you run npm install, does not download the module

Note that
the specific installation position, can be provided by npm config prefix, or viewed through npm config list

NPM install moduleName

  • Installing the module into the current folder node_modules
  • The module does not write information to or dependencies node devDependencies
  • When you run npm install, does not download the module

to sum up

The modules are under development devDependencies node when needed, such as the build tool glup, useful for WebPACK, preprocessor less, sass these only in the development environment, the use of mounting -save-dev

Dependencies module in the node is required to run the code line, such as axios, vue-router, vuex, it is required to install -save

Transfer: https://blog.csdn.net/Liu_yunzhao/article/details/90517622

Guess you like

Origin www.cnblogs.com/vickylinj/p/12108189.html