Yarn is a new package management tool from Facebook, it is designed to solve daily development issues using NPM client. There are lots of posts to explain the advantages of Yarn. And the beauty of this tool is: Yarn is compatible with NPM and bower.
Here are some frequent commands for Yarn usage:
yarn init
yarn add [package]
yarn add [package]@[version]
yarn add [package]@[tag]
yarn upgrade [package]
yarn upgrade [package]@[version]
yarn upgrade [package]@[tag]
yarn remove [package]
yarn install
Installing all dependencies: yarn or yarn install
Installing one and only one version of a package: yarn install --flat
Forcing a re-download of all packages: yarn install --force
Installing only production dependencies: yarn install --production
Yarn reads package.json, generate yarn.lock file. These two key files are expected to check into version control system to share across team, so that each team member will get the same dependency list and install the same packages on different machines.
Developer can use npm and yarn at the same time, but we strongly recommend to use yarn to manage the packages due to the pitfalls from npm. The commands are easy to remember too.
yarn add -> npm install -save
yarn upgrade -> npm update (up, upgrade)
yarn remove -> npm uninstall
yarn install -> npm install
No comments:
Post a Comment