Getting Started with DevOps (ii) package management tool yarn vs. NPM

Source: Internet
Author: User
Tags json

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












Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.