当前位置:网站首页>Why give up NPM and turn to yarn
Why give up NPM and turn to yarn
2022-07-26 11:08:00 【Don Juan taro】
List of articles
Preface
yarn and npm Are excellent package management tools , Redesigned npm client yarn, There is no doubt that is npm plus edition , It solves the problem that developers use npm Pain points encountered during
One 、yarn What is it? ?
yarn Is a new generation of package management tools , The tool is made up of Facebook and Goole Wait for the company to 2016 Jointly launched in .yarn There's a significant increase in speed , Less installation time , There are also many improvements in function
Two 、 Installation steps
1. Import and stock in
The code is as follows ( Example ):
npm install -g yarn
2.npm disadvantages
- Slow download speed : because npm The plug-ins are downloaded from foreign servers , It is far less fast than downloading from domestic servers , To solve this pain , Taobao team made the domestic version npm be called
cnpm, And right npm Mirrored , We only need to install globally cnpm , also registry become Taobao image file , This wave of operation has greatly solved the problem of download speed
npm install -g cnpm --registry=https://registry.npm.taobao.org
- The same project , The installed cannot be consistent . The reason is because package.json The characteristics of the version number in the document lead to , The following three version numbers represent different meanings during installation .
"1.0.1" # Indicates the installation of the specified 1.0.1 edition
"~1.0.1" # Said the installation 1.0.X The latest version of
"^1.0.1" # Said the installation 1.X.X The latest version of
3.yarn advantage
- The download speed of the bottom layer
npm It is serially executed according to the queue package, and yarn Perform all tasks synchronously in parallel , The performance has been greatly improved .
- Unified version installation
yarn Medium lock file Specifically record the version number of the installed module . Just add one module at a time ,yarn It will update yarn.lock
This file . This ensures that every time you pull the same project dependency , The same module version is used .
- Concise output
npm In execution npm install When , The command line will continuously print out all installed dependencies , A lot of useless redundant information , and yarn During the installation process, only the necessary information will be printed
3、 ... and 、yarn Command changes
- registry Mirror image
npm install -g cnpm --registry=http://registry.npm.taobao.org
yarn config set registry 'https://registry.npm.taobao.org'
- Initialize a project
npm init
yarn init
- The installation project depends on
npm install
yarn install
- Install third party dependencies
npm install <package>
yarn add <package>
- Remove dependency
npm uninstall <package>
yarn remove <package>
- Update dependency
npm update <package>
yarn upgrade <package>
- Install global project dependencies
npm install <package>-g
yarn global add <package>
- Install project dependencies for a specific version number
npm install <package>@1.2.33
yarn add <package>@1.2.33
- Contract awarding / Sign in / Logout operation
npm publish/login/logout
yarn publish/login/logout
- Run the command
yarn run/test
summary
for example : That's what we're going to talk about today , This article only briefly introduces yarn and npm The use of commands and yarn The advantages of
边栏推荐
- The assignment of member pointer defined in C structure and the use of structure pointer as member function parameter
- 配置文件以rc结尾什么意思
- Toolstrip border removal
- 看源码之LinkedList
- @The difference and use of jsonformat and @datetimeformat
- @NotBlank、@NotNull 、@NotEmpty 区别和使用
- Fragment 懒加载
- UDF and analysis case of sparksql, 220725,
- Logging learning final edition - configured different levels of log printing colors
- ISO 639:1988 : Code for the representation of names of languages
猜你喜欢
随机推荐
Esxi6.5 patch update
Bash shell学习笔记(六)
Multipartfil to file
Sword finger offer (53): a string representing a numeric value
List ascending and descending
ArrayList of novice source code
PyQt5快速开发与实战 3.1 Qt Designer快速入门
Pytest fixture decorator
Sword finger offer (V): queue with two stacks
Bash shell学习笔记(二)
ISO 639:1988 : Code for the representation of names of languages
1837. Sum of digits under k-ary representation
BLE之ATT请求
Bash shell learning notes (I)
C notes
Shell script fails to execute repeatedly automatically
Bash shell learning notes (6)
脉冲波形的产生与变换
PyQt5快速开发与实战 第1章 认识PyQt5
349. Intersection of two arrays









