当前位置:网站首页>Yarn installation and use tutorial [easy to understand]
Yarn installation and use tutorial [easy to understand]
2022-07-25 18:48:00 【Full stack programmer webmaster】
Hello everyone , I meet you again , I'm your friend, Quan Jun .
One 、 Official website guidelines
English official website :Yarn English official website
Chinese document :Yarn Chinese document
Two 、Yarn Introduce
Yarn yes Facebook, Google, Exponent and Tilde Developed a new JavaScript Package management tools . You can use code from developers all over the world , Or share your own code . The code passes through the package (package)( Or module (module)) To share . A package contains all the code that needs to be shared , And files that describe package information , be called package.json. Its advantage is faster 、 More secure 、 More reliable . Its main features are offline mode 、 deterministic 、 network performance 、 Sign up more 、 Network resilience 、 Flat mode and Emoji.
3、 ... and 、Yarn The advantages of
Fast :Yarn Cache every downloaded package , So you don't have to download it again when you use it again . At the same time, parallel downloads are used to maximize resource utilization , So it's faster to install .
reliable : Use details 、 Simple lock file format and clear installation algorithm ,Yarn It can ensure no different work on different systems .
Security : Before executing the code ,Yarn The integrity of each installation package will be verified through the algorithm .
Four 、window System installation Yarn
【1】 Download the installation package to install
Click me to download Yarn Installation package , You will download to a .msi file , When it runs, it will guide you to Yarn The installation to Windows On . If you use this installer , You need to install Node.js.
【2】 adopt Chocolatey install
Chocolatey It's a Windows Special software package management tools . Please follow this explain install Chocolatey . install Chocolatey after , You can execute the following commands on the console to install Yarn 了
choco install yarn【3】 adopt Scoop install
Scoop Is a Windows Command line based installation tool . Please follow this explain install Scoop .Scoop After installation , You can execute the following commands on the console to install Yarn 了
scoop install yarn5、 ... and 、Linux System installation Yarn
【1】 Execute the official website installation script with one click
curl -o- -L https://yarnpkg.com/install.sh | bash -s -- --nightly【2】 adopt npm install
npm install -g yarn【3】 Check the version after installation
yarn --version6、 ... and 、Yarn Common commands
【1】 Initiate a new project
yarn init【2】 Add dependency package
yarn add [package] // The latest version will be automatically installed , Will overwrite the specified version number
yarn add [package] [package] [package] // Add multiple packages at once
yarn add [package]@[version] // Add the specified version of the package
yarn add [package]@[tag] // Install a tag( such as beta,next perhaps latest)【3】 Add dependencies to different dependency categories
Do not specify a dependency type. Install to by default dependencies in , You can also specify dependency types to be added to devDependencies、peerDependencies and optionalDependencies
yarn add [package] --dev or yarn add [package] -D // Add to devDependencies
yarn add [package] --peer or yarn add [package] -P // Add to peerDependencies
yarn add [package] --optional or yarn add [package] -O // Add to optionalDependencies【4】 Upgrade dependency package
yarn upgrade [package] // Upgrade to the latest version
yarn upgrade [package]@[version] // Upgrade to the specified version
yarn upgrade [package]@[tag] // Upgrade to specified tag【5】 Remove dependency package
yarn remove [package] // Remove package 【6】 install package.json Package dependency in , And save the package and all its dependencies into yarn.lock
yarn or yarn install // Install all dependencies
yarn install --flat // Install a single version of a package
yarn install --force // Force all packages to be downloaded again
yarn install --production // Only install production environment dependencies 【7】 Release package
yarn publish【8】 Run script
yarn run // Used to perform the package.json in scripts Property 【9】 Show information about a package
yarn info [package] // It can be used to view the latest version information of a module 【10】 cache
yarn cache
yarn cache list // List each package that has been cached
yarn cache dir // Returns the global cache location
yarn cache clean // Clear cache 7、 ... and 、yarn and npm Command comparison
NPM | Yarn | explain |
|---|---|---|
npm init | yarn init | Initialize a project |
npm install/link | yarn install/link | The default installation depends on |
npm install taco –save | yarn add taco | Install a dependency and save it to by default package |
npm uninstall taco –save | yarn remove taco | Remove a dependency |
npm install taco –save -dev | yarn add taco -dev | Install a development dependency |
npm update taco –save | yarn upgrade taco | Update a dependent project |
npm install taco –global | yarn global add taco | Install a global dependency project |
npm publish/login/logout | yarn publish/login/logout | Release / Sign in / sign out |
npm run/test | yarn run/test | Run a command |
Publisher : Full stack programmer stack length , Reprint please indicate the source :https://javaforall.cn/127584.html Link to the original text :https://javaforall.cn
边栏推荐
猜你喜欢

Powell's function of Ceres

【开源工程】STM32C8T6+ADC信号采集+OLED波形显示

The Yellow Crane Tower has a super shocking perspective. You've never seen such a VR panorama!

Advanced software testing - test classification

项目:串口接收—ram存储—TFT显示(完整设计)

单臂路由实验演示(Huawei路由器设备配置)

Vc/pe is running towards Qingdao

What is the difference between GB and gib disk space units?

A brief history from object detection to image segmentation

进程通信(SystemV通信方式:共享内存,消息队列,信号量)
随机推荐
优秀的测试/开发程序员突破,不忘初心,方得始终......
Ceres analytic derivation
SQL realizes 10 common functions of Excel, with original interview questions attached
What is 3DE experience platform
Qtimgui 编译
Partial correlation calculation of R language and partial correlations calculation using pcor function of GGM package
动态内存管理
#yyds干货盘点# 面试必刷TOP101:反转链表
Care for front-line epidemic prevention workers, Haocheng JIAYE and Gaomidian sub district office jointly build the great wall of public welfare
Is Cinda securities a state-owned enterprise? Is it safe to open an account in Cinda securities?
Paper revision reply 1
Add a little surprise to life and be a prototype designer of creative life -- sharing with X contestants in the programming challenge
7/24 training log
Esp32 S3 vscode+idf setup
You can change this value on the server by setting the 'Max_ allowed_ Packet 'variable error
[translation] LFX 2022 spring tutor qualification opening - apply for CNCF project before February 13!
Yyds dry inventory interview must brush top101: reverse linked list
What is the difference between GB and gib disk space units?
Interface automation test platform fasterrunner series (IV) - continuous integration and solution of multi domain names
大厂云业务调整,新一轮战争转向