官方文檔只是簡單的說:
--save: Package will appear in your dependencies.
--save-dev: Package will appear in your devDependencies.
真正的區別是:
--save-dev:
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。
--save:
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.
dependencies下的模塊,是我們生產環境中需要的依賴。
參考鏈接http://imcodebased.com/npm-save-or-save-dev-which-one-to-use/