好,想必你對新的 JavaScript
包管理工具 yarn
已經有所耳聞,並已經過 npm i -g yarn
進行了安裝,如今想知道怎麼樣使用嗎?若是你瞭解 npm
,你已經會很大一部分啦!css
下面是我從 npm 切換到 yarn 的一些筆記。html
👍 請收藏本文,本文會隨着 yarn
的升級而更新。git
npm install === yarn
# 默認安裝行爲
npm install taco --save === yarn add taco
# 將 taco 安裝並保存到 package.json 中
npm uninstall taco --save === yarn remove taco --save
# 在 npm 中,可使用 npm config set save true 設置 —-save 爲默認行爲,但這對多數開發者而言並不是顯而易見的。在 yarn 中,在 package.json 中添加(add)和移除(remove)等行爲是默認的。
npm install taco --save-dev === yarn add taco --dev
npm update --save === yarn upgrade
# update(更新) vs upgrade(升級), 贊!upgrade 纔是實際作的事!版本號提高時,發生的正是 upgrade !
# 注意: npm update --save 在版本 3.11 中彷佛有點問題。
npm install taco@latest --save === yarn add taco
npm install taco --global === yarn global add taco
# 一如既往,請謹慎使用 global 標記。
複製代碼
你可使用
yarn self-update
來更新它本身github
registry
的和 NPM
上是同樣的。大體而言,Yarn
只是一個新的安裝工具,NPM
結構和 registry
仍是同樣的。npm
npm init === yarn init
npm link === yarn link
npm outdated === yarn outdated
npm publish === yarn publish
npm run === yarn run
npm cache clean === yarn cache clean
npm login === yarn login
# 和 logout 是同樣的
npm test === yarn test
npm install --production === yarn --production
複製代碼
我跳過了一些提醒咱們不要使用的內容,如 yarn clean
。json
yarn licenses ls
# 容許您檢查您的依賴的許可證
yarn licenses generate-disclaimer
# 自動建立您的許可證免責聲明
yarn why taco
# 肯定爲何安裝了 taco 檢查爲何會安裝 taco,詳細列出依賴它的其餘包(感謝 Olivier Combe).
Emojis ⬆️
速度 🏃⌁
經過 yarn lockfile 自動實現 shrinkwrap 功能
以安全爲中心的設計
yarn upgrade-interactive
# 容許您本身選擇升級指定的包
複製代碼
npm xmas === NO EQUIVALENT
npm visnup === NO EQUIVALENT
複製代碼
這篇備忘手冊的 PDF
版本特別感謝 Justin Huskey安全
PDF文件連接bash
原文連接: NPM vs Yarn Cheat Sheet工具
https://yarn.bootcss.com/post
https://github.com/yarnpkg/yarn