Yarn by Facebook, Google, Exponent and Tilde jointly launched a new JS package management tool, it is mainly to make up for some shortcomings of the emergence of npm. And npm, it has the following characteristics:
-
Speed: mainly from the following two aspects:
-
Parallel installation: parallel execution of all tasks, improving performance.
-
Offline mode: directly from the cache if a package has been previously installed, install again.
-
Installation unified version: Every time when pulling the same project dependencies, module versions are the same use.
-
More concise output: the Yarn combines intuitive and emoji directly print out the necessary information, but also provides commands for developers to query additional installation information.
-
Multi-source registration process: all dependencies, when no matter how many times he was quoted indirectly associated with different libraries, install this package, only from a registered source to install either npm either bower, to prevent inconsistencies confusion.
-
Better semantics: the Yarn command npm changed some names, such as yarn add / remove, to feel more clearly than the original npm install / uninstall.
Installation Yarn
In the case of the npm installed, it can be used directly to install npm yarn
npm install -g yarn
Enter yarn -v, correctly displays the version number of the installation was successful. If you want to manually install, you can refer directly to the official document: https://yarnpkg.com/zh-Hans/docs/install
In addition, because Fangxiao Zhang divinity, leading to foreign websites may from time to time drifted on Mars. At this point you can use Taobao to accelerate download mirror:
yarn config set registry https://registry.npm.taobao.org
Use Yarn
yarn and command npm almost, specifically refer to the official documentation: https://yarnpkg.com/zh-Hans/docs . Here is a list about common commands.
asl |
Yarn |
Explanation |
nPM heat |
yarn init |
Initialization package development environment |
npm install |
yarn install |
Installation package definition file all dependent |
npm install xxx —save |
yarn add xxx |
Install a dependent, saved by default in the package |
npm uninstall xxx —save |
yarn remove xxx |
Remove a dependent project |
npm install xxx —save-dev |
yarn add xxx —dev |
When you install a development project relies |
npm update xxx —save |
yarn upgrade xxx |
Update a dependent project |
npm install xxx --global |
yarn global add xxx |
The installation of a global dependency project |
Elevation run / test |
yarn run/test |
Run a command |
Reprinted from: https: //www.cnblogs.com/TianFang/p/10106458.html
Yarn by Facebook, Google, Exponent and Tilde jointly launched a new JS package management tool, it is mainly to make up for some shortcomings of the emergence of npm. And npm, it has the following characteristics:
-
Speed: mainly from the following two aspects:
-
Parallel installation: parallel execution of all tasks, improving performance.
-
Offline mode: directly from the cache if a package has been previously installed, install again.
-
Installation unified version: Every time when pulling the same project dependencies, module versions are the same use.
-
More concise output: the Yarn combines intuitive and emoji directly print out the necessary information, but also provides commands for developers to query additional installation information.
-
Multi-source registration process: all dependencies, when no matter how many times he was quoted indirectly associated with different libraries, install this package, only from a registered source to install either npm either bower, to prevent inconsistencies confusion.
-
Better semantics: the Yarn command npm changed some names, such as yarn add / remove, to feel more clearly than the original npm install / uninstall.
Installation Yarn
In the case of the npm installed, it can be used directly to install npm yarn
npm install -g yarn
Enter yarn -v, correctly displays the version number of the installation was successful. If you want to manually install, you can refer directly to the official document: https://yarnpkg.com/zh-Hans/docs/install
In addition, because Fangxiao Zhang divinity, leading to foreign websites may from time to time drifted on Mars. At this point you can use Taobao to accelerate download mirror:
yarn config set registry https://registry.npm.taobao.org
Use Yarn
yarn and command npm almost, specifically refer to the official documentation: https://yarnpkg.com/zh-Hans/docs . Here is a list about common commands.
asl |
Yarn |
Explanation |
nPM heat |
yarn init |
Initialization package development environment |
npm install |
yarn install |
Installation package definition file all dependent |
npm install xxx —save |
yarn add xxx |
Install a dependent, saved by default in the package |
npm uninstall xxx —save |
yarn remove xxx |
Remove a dependent project |
npm install xxx —save-dev |
yarn add xxx —dev |
When you install a development project relies |
npm update xxx —save |
yarn upgrade xxx |
Update a dependent project |
npm install xxx --global |
yarn global add xxx |
The installation of a global dependency project |
Elevation run / test |
yarn run/test |
Run a command |
Reprinted from: https: //www.cnblogs.com/TianFang/p/10106458.html