Yarn 和 Npm 命令行切换 摘录
原文作者:?@Gant Laborde
原文地址:?https://shift.infinite.red/np...
中文翻譯:?@文藺
譯文地址:http://www.wemlion.com/2016/n...
?
好,想必你對新的 JavaScript 包管理工具?yarn?已經有所耳聞,并已通過?npm i -g yarn?進行了安裝,現在想知道怎么樣使用嗎?如果你了解 npm,你已經會很大一部分啦!
下面是我從 npm 切換到 yarn 的一些筆記。
請收藏本文,本文會隨著 yarn 的升級而更新。
需要了解的命令
-
npm install?===?yarn?—— install 安裝是默認行為。
-
npm install taco --save?===?yarn add taco?—— taco 包立即被保存到?package.json?中。
-
npm uninstall taco --save?===?yarn remove taco
在 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 標記。
已知悉的命令
包和 npm registry 上是一樣的。大致而言,Yarn 只是一個新的安裝工具,npm 結構和 registry 還是一樣的。
-
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
Yarn 獨有的命令
我跳過了一些提醒我們不要使用的內容,如?yarn clean。
-
yarn licenses ls?—— 允許你檢查依賴的許可信息。
-
yarn licenses generate?—— 自動創建依賴免責聲明 license。
-
yarn why taco?—— 檢查為什么會安裝 taco,詳細列出依賴它的其他包(鳴謝?Olivier Combe)。
-
Emojis
-
速度
-
通過 yarn lockfile 自動實現 shrinkwrap 功能
-
以安全為中心的設計
Npm 獨有的命令
-
npm xmas?===?NO EQUIVALENT
-
npm visnup?===?NO EQUIVALENT
筆者寫作本文時, yarn 的?run?命令似乎出了點問題,應該會在?0.15.2?中修復。在這一點上, npm 好多了。感謝?Zachary?的研究!
還有更多呢!
值得一看
-
Yehuda Katz using Yarn?—?http://yehudakatz.com/2016/10/11/im-excited-to-work-on-yarn-the-new-js-package-manager-2/
-
Facebook Announce?—?https://code.facebook.com/posts/1840075619545360
-
News?—?http://thenextweb.com/dd/2016/10/12/facebook-launches-yarn-a-faster-npm-client/
-
Benchmarking?—?https://www.berriart.com/blog/2016/10/npm-yarn-benchmark/
進階閱讀
-
https://yarnpkg.com/en/docs/
-
https://twitter.com/yarnpkg
-
https://github.com/yarnpkg/yarn
-
https://yarnpkg.com/en/docs/migrating-from-npm
-
轉載于:https://www.cnblogs.com/y-lin/p/6532580.html
總結
以上是生活随笔為你收集整理的Yarn 和 Npm 命令行切换 摘录的全部內容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: iPhone 连接电脑后,点击“信任”没
- 下一篇: iPhone12什么时候上市 4G版iP