当前位置:网站首页>The difference between NPM install -g/-save/-save-dev

The difference between NPM install -g/-save/-save-dev

2022-07-05 07:03:00 Underwater barbecue shop AI

npm install XX ( Shorthand for npm i XX)

  • Will be able to XX Package installed in node_modules Directory
  • stay npm5 Before the release ,XX Will not automatically write package.json
  • stay npm5 Then it will be written automatically package.json Of dependencies Properties of the ( And --save identical )

npm install XX -g

  • -g Means to install the module to overall situation , Where to install on the disk , Want to see npm config prefix The location of

  • The specific check method is to input npm config edit, Find in the pop-up document ; prefix=C:\node Is it

npm install XX --save( Shorthand for npm i XX -S)

  • Will be able to XX Package installed in node_modules Directory ,

  • Will be in package.json Of dependencies Add... Under properties XX

  • - function npm install --production Or annotate NODE_ENV Variable value is production when ( Installation in production environment depends on ), The module will be automatically downloaded to node_modules Directory .

  • stay npm5 Then it can be npm i xx replace

dependencies The dependency in is Dependencies in the production environment , It will also be installed in the production environment after the project deployment , for example :

It was used axios request , Because it still needs to be used after release to production axios, This will make axios The installation to dependencies

npm install XX --save-dev( Shorthand for npm i XX -D)

  • Will be able to XX Package installed in node_modules Directory

  • Will be in package.json Of devDependencies Add... Under properties XX

  • function npm install --production Or annotate NODE_ENV Variable value is production when ( Installation in production environment depends on ), Modules will not be automatically downloaded to node_modules Directory .

devDependencies The dependency in is Dependency only in the development environment , It will not be installed in the production environment after the project deployment , for example :

Write ES6 Code , need babel convert to es5 , After the conversion , We just need the converted code , When you go online , Directly deploy the converted code to the production environment , Unwanted bebal 了 , The production environment doesn't need , This will make babel The installation to devDependencies

原网站

版权声明
本文为[Underwater barbecue shop AI]所创,转载请带上原文链接,感谢
https://yzsam.com/2022/186/202207050641436243.html