Reference: First, yarn
FaceBook is open source for yarn, a new JavaScript package management tool that works with Exponent, Google, and tilde. Yarn, known as the NPM upgrade, was developed primarily to address the pain points of NPM, which can actually be mixed in general use, unless it is found that NPM's flaws are intolerable.
Yarn's Highlights:
Extreme fast: Cache already downloaded packages, avoid duplicate downloads, this feature is much better than NPM, do not need to download offline mode every time: Previously downloaded packages, can be installed offline again security: Before the download will check the signature and the integrity of the package is reliable to ensure the consistency of the platform dependencies: Yarn.lock stores this exact dependency version of each of your packages, ensuring that you have exactly the same dependent version on all machines from the local development to the production environment. Network optimization: Strive to maximize the utilization of network resources, so that resources to download the perfect queue execution, to avoid a large number of useless requests, download failure will automatically re-request, to avoid the entire installation process failure Flattening mode: Create a separate package for mismatched dependent versions of the package, avoid creating duplicates. Yarn Installation: The installation of yarn under Mac can use the terminal URL in the way:
curl-o--L https://yarnpkg.com/install.sh | Bash
second, the use of yarn
2.1 Yarn Initialization
The initialization of yarn is as follows:
Name: Project name version
: Release number
Description: Item Description
entry point: Portal file
git repository:git Project link address
Author: author
license: protocol
2.2 Adding dependencies
The same thing with NPM is that when a module that is defined in the Package.json is installed with a different version number, a Package-lock.json file is generated (yarn generates a file named Yarn.lock). Used to keep the first version number state, and yarn and npm differ in that yarn updates Package.json and Yarn.lock to the latest after each installation, and NPM does not modify the lock file.
Yarn Add [package]-Add package, will automatically install the latest version, note will overwrite the specified version number ...
Yarn Add [package]@[version]-with version number installation
Yarn Upgarde -will traverse all dependencies and then update all to the latest version
Yarn Remove [package]-Remove a package
Yarn-Install all dependent
yarn Install -Install all dependencies
Yarn Add--dev added to devdependencies
yarn Add--peer added to peerdependencies
yarn add--optional to Optionaldependenci Es