跳到主要内容

1 篇博文 含有标签「yarn」

查看所有标签

· 阅读需 3 分钟

Why Yarn

Yarn is Super Fast!!

Yarn caches every package it downloads so it never needs to again. It also parallelizes operations to maximize resource utilization so install times are faster than ever.

Common NPM commands in Yarn

NPM CommandYarn CommandDescription (wherever necessary)
npm installyarn
yarn install
Will install packages listed in the package.json file
npm install pkg-name
npm install --save pkg-name
yarn add pkg-nameBy default Yarn adds the pgk-name to package.json and yarn.lock files
npm install pkg-name@1.0.0yarn add pgk-name@1.0.0
npm install pkg-name --save-devyarn add pkg-name --dev
npm install pkg-name --peeryarn add pkg-name--peer
npm install pkg-name --optionalyarn add --optional
npm install -g pkg-nameyarn global add pkg-nameCareful, yarn add global pkg-name adds packages global and pkg-name locally!
npm updateyarn upgradeNote: It's called upgrade in yarn
npm uninstall pkg-nameyarn remove pkg-name
npm run script-nameyarn run script-name
npm inityarn init
npm packyarn packCreates a compressed gzip archive of the package dependencies
npm linkyarn link
npm outdatedyarn outdated
npm publishyarn publish
npm runyarn run
npm cache cleanyarn cache clean
npm loginyarn login (and logout)
npm testyarn test
npm install --productionyarn --production
npm --versionyarn version
npm infoyarn info

New Commands in Yarn

Yarn CommandDescription
yarn why pkg-name Builds a dependency graph on why this package is being used
yarn cleanFrees up space by removing unnecessary files and folders from dependencies
yarn licenses ls  Inspect the licenses of your dependencies
yarn licenses generate-disclaimer  Automatically create your license dependency disclaimer

References

https://yarnpkg.com/en/docs/


参考

https://github.com/areai51/yarn-cheatsheet

https://shift.infinite.red/npm-vs-yarn-cheat-sheet-8755b092e5cc