Yarn是由Facebook、Google、Exponent 和 Tilde 聯合推出了一個新的 JS 包管理工具
Yarn 是為了彌補 npm 的一些缺陷而出現的(比如,npm install時候會很慢以及安全問題)
Yarn的優點:
1、速度快(並行安裝和離線模)
2、安裝版本統一
3、輸出更簡潔
4、語義化更好
npm5.0也較之前做出了調整
比如:
1、默認新增了類似yarn.lock的 package-lock.json
2、git 依賴支持優化
3、文件依賴優化
yarn和npm一些命令對比:
初始化項目
npm init
yarn init
默認安裝依賴
npm install/link yarn install/link
/* npm install 命令會根據 package.json 安裝依賴以及允許你添加新的模塊 yarn install 僅會按 yarn.lock 或 package.json 里面的依賴順序來安裝模塊 */
安裝某個依賴,並且默認保存到package
npm install taco —save
yarn add taco
移除某個依賴項目
npm uninstall taco —save
yarn remove taco
更新某個依賴項目
npm update taco —save
yarn upgrade taco
運行某個命令
npm run/app yarn run/app
參考文檔:
http://web.jobbole.com/88459/