The role and difference of -S and -D when npm installs dependencies

-S

  That is --save (save)

  The package name will be registered in the dependencies of package.json, and the dependencies of this package still exist in the production environment.

 

-D

  Ie --dev (production)

  The package name will be registered in the devDependencies of package.json, and only use -D for packages that exist in the development environment, such as parsers such as babel and sass-loader

 

Write nothing

  The package name will not enter package.json, so others do not know that this package is installed, so this is not recommended.

 

npm install -d means npm install --save-dev is installed to the development environment. For example, gulp, babel, webpack are generally auxiliary tools

npm install -s is npm install --save installed to the production environment, such as vue, react, etc.

 

The difference between npm i and npm install -s and -d:

  npm i module_name -S => npm install module_name --save the dependencies object written to package.json

  npm i module_name -D => npm install module_name --save-dev writes to the devDependencies object of package.json

  npm i module_name -g global installation

  i is short for install

  -S is short for --save

  -D is shorthand for --save-dev

  The plugins in devDependencies are only used in the development environment, not in the production environment, and dependencies need to be released to the production environment. Tools such as gulp, babel, and webpack for compressing code and packaging are not needed in actual operation, so use -D; think that plug-ins such as elementui and echarts are also needed in actual operation, so use -S.

 

 

package-lock.json file: Store the data of some packages that have been downloaded before, so that they can be quickly found during the next installation.

 

Original: https://www.cnblogs.com/wuqilang/p/12333485.html

Guess you like

Origin blog.csdn.net/cherry_vicent/article/details/113861205