npm & Yarn

npm、Yarn 命令对照表

常用

npm yarn
npm install yarn
npm install [package] --save yarn add [package]
npm uninstall [package] --save yarn remove [package]
npm install [package] --save-dev yarn add [package] --dev
npm update --save yarn upgrade
npm install [package]@latest --save yarn add [package]
npm install [package] --global yarn global add [package]

差异

npm yarn
npm install yarn
(N/A) yarn install --flat
(N/A) yarn install --har
(N/A) yarn install --no-lockfile
(N/A) yarn install --pure-lockfile
npm install [package] (N/A)
npm install --save [package] yarn add [package]
npm install --save-dev [package] yarn add [package] --dev
(N/A) yarn add [package] --peer
npm install --save-optional [package] yarn add [package] --optional
npm install --save-exact [package] yarn add [package] --exact
(N/A) yarn add [package] --tilde
npm install --global [package] yarn global add [package]
npm uninstall [package] (N/A)
npm uninstall --save [package] yarn remove [package]
npm uninstall --save-dev [package] yarn remove [package]
npm uninstall --save-optional [package] yarn remove [package]
rm -rf node_modules && npm install yarn upgrade

相同

npm yarn
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 (and logout)
npm test yarn test
npm install --production yarn --production

Yarn 独有

  • yarn licenses ls
  • yarn licenses generate-disclaimer
  • yarn why [package]

npm 独有

  • npm xmas
  • npm visnup

参考


本文采用 CC BY-NC-SA 3.0 CN 许可协议,转载请注明出处。
本文地址: http://blog.ralfz.com/2017/04/24/npm-vs-yarn/