Some projects require NPM to download dependencies and execute RUN, while others require YARN. Generally speaking, YARN has the following advantages:

  • Fast installation speed
  • Version of the lock
  • Caching mechanisms
  • Grammar concise

Contrast YARN with NPM

yarn npm instructions
yarn npm install The installation
yarn add xxx npm install xxx –save Install a dependency and save it to the Package
yarn remove xxx npm uninstall xxx –save uninstall
yarn add xxx –dev npm install xxx –save-dev
yarn upgrade npm update –save update
yarn –version npm -version Check the version
yarn init npm init Initialize the project
Yarn config set registry ‘Registry.npm.taobao.org ‘ npm install -g cnpm –registry=registry.npm.taobao.org Replace taobao mirror

The installation

1. Install using Homebrew

brew install yarn
Copy the code

Ps: If the network is not good, you will fail. You are advised to try multiple times

2. Script installation

curl -o- -L https://yarnpkg.com/install.sh | bash
Copy the code

Ps: simple and fast, suitable for the domestic network environment