Get the App
SLTechnology News&Howtos  ›  Development  › 

What are the advantages of Yarn

Shulou Source: shulou.com Published: 2022-06-02 15:54:22 10月17日 Update

This article mainly explains "what are the advantages of Yarn". The content of the explanation is simple and clear, and it is easy to learn and understand. Please follow the editor's ideas to study and learn "what are the advantages of Yarn"?

Yarn is a fast, reliable and secure dependency management tool. Compared with npm, yarn has many advantages, the main advantages are: high speed, offline mode, version control.

Advantages of yarn

1. High speed

Npm waits for one package to be fully installed before skipping to the next, but yarn executes the package in parallel, so it's much faster. On the Internet, there are a lot of npm and yarn installation rely as much on the execution speed, yarn has obvious advantages in terms of speed. Experience the same flying speed in the actual project, who knows who has tried it?

2. Offline mode

The principle of offline is relatively simple, the installed package will be saved in the cache directory, and then the installation will be copied directly from the cache. The essence of doing so will still improve the speed of installation and download and avoid unnecessary network requests.

3. Version control

One of the stronger pain points of npm is that version control is not accurate enough when the dependency level of the package is deep. Yarn is inherently version-hardened. A npm-shrinkwrap.json-like yarn.lock file is generated that describes the version number of the package itself and locks the version numbers of all packages it depends on.

Installation of yarn

1. Install Chocolatey. After installing Chocolatey, you can install Yarn with the following instructions:

Chocoinstallyarn

The installation method also requires that you install Node.js in advance.

Yarn usage

Initialize a new project

Yarninit

Add a dependency package

Yarnadd [package]

Yarnadd [package] @ [version]

Yarnadd [package] @ [tag]

Update a dependency package

Yarnupgrade [package]

Yarnupgrade [package] @ [version]

Yarnupgrade [package] @ [tag]

Delete a dependency package

Yarnremove [package]

Install all dependent packages

Yarn

Or

Yarninstall

Thank you for your reading, the above is the content of "what are the advantages of Yarn". After the study of this article, I believe you have a deeper understanding of what the advantages of Yarn are, and the specific use needs to be verified in practice. Here is, the editor will push for you more related knowledge points of the article, welcome to follow!

Tags: Speed version advantage advantage learning control content that is file mode cache fast project obvious accurate secure not enough principle can be passed actual Apple Docker Huawei Linux macOS MariaDB Microsoft MySQL NVidia OPPO Reno Apple Shulou Information Xiaomi OPPO Reno MariaDB