npm install --save/--save-dev的区别


--save: Package will appear in your dependencies. 

--save-dev: Package will appear in your devDependencies.



dev指的是development:This is useful when installing development-only packages, like grunt, gulp or your testing library. Thus, when you are distributing your code to production, these dependencies will not be available.

这就是说,devDependencies下列出的模块,是我们开发时用的,比如grunt-contrib-uglify, 我们用它来混淆js文件,它们不会被部署到生成环境。有一个方法可以很好的检验这一点,将node_modules删掉,然后npm install --production会发现,只会安装到dependencies。

以及其他方便我们开发的工具,比如angular, vue, sass等都只需要安装到devDependencies。


You will use this option when you want to save a package dependency for distribution. Item such as angularjs, or any other module that is required at run time by your program.




posted @ 2016-11-23 10:17  kakaguo  阅读(2188)  评论(0编辑  收藏  举报