npm --save-dev --save 的区别2

时间:2021-04-02 10:45:31   收藏:0   阅读:14

npm install 在安装 npm 包时,有两种命令参数可以把包的信息写入 package.json 中

  1. npm install --save-dev 缩写:npm i -D xxx

    会把依赖包名称添加到 package.json 中的 dependencies 键下,

  1. npm install --save 缩写:npm i -S xxx

    会把依赖包名称添加到 package.json 中的 devDependencies 键下

 

区别:

  devDependencies:

    devDependencies下列出的模块,是仅在开发的时候用的,发布之后不用的。

  dependencies:

    dependencies下列出的模块,开发和发布后都会用到,否则项目就运行不了。

 

注:

  我们 npm install 时,会下载 devDependencies 和 dependencies 的所有模块

  我们 npm install --production 或者 NODE_ENV 变量值为 production 时,只下载 dependencies 中的模块。

 

原文:https://www.cnblogs.com/liql/p/14609407.html

评论(0
© 2014 bubuko.com 版权所有 - 联系我们:wmxa8@hotmail.com
打开技术之扣,分享程序人生!