npm install --save/--save-dev的區別


官方文檔只是簡單的說:

--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/


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM