当前位置:网站首页>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
边栏推荐
- 菜鸟看源码之LinkedBlockingQueue
- SparkSQL的UDF及分析案例,220725,
- Esxi6.5 patch update
- Sword finger offer (V): queue with two stacks
- Sword finger offer (49): convert a string to an integer
- 232. Implement queue with stack
- 【转载】多元高斯分布(The Multivariate normal distribution)
- nmap弱点扫描结果可视化转换
- Classified by the number of 1 in binary number
- Dictionary and int matrix
猜你喜欢
随机推荐
C notes
Le audio specification overview
线程之间的几种通信方式
1837. Sum of digits under k-ary representation
Visual conversion of nmap vulnerability scanning results
Scrapy ip代理无响应
Pytest case execution sequence
Wechat official account development obtains openid times error 40029 invalid code solution
菜鸟看源码之HashTable
Interview knowledge points
0x00007ffd977c04a8 (qt5sqld.dll) (in a.exe): 0xc0000005: an access violation occurred when reading position 0x0000000000000010
@The real difference and usage between validated and @valid
104. Maximum depth of binary tree
企鹅龙(DRBL)无盘启动+再生龙(clonezilla)网络备份与还原系统
-bash: ./build. Sh: /bin/bash^m: bad interpreter: no that file or directory
mother
SparkSQL的UDF及分析案例,220725,
Connection between PLC and servo motor
27. Remove elements
菜鸟看源码之SparseArray









