Yarn 2 - Install and disassemble

Acquaintance

Yarn 2 (Berry) is a new release of the revolutionary and well-established Yarn package manager, including features such as Plug'n'Play, modular API extensibility, offline cache, and improved workspace support.





Plug'n'Play

Yarn PnP is a new feature that is included by default in Yarn 2. PnP dumps projects from the node_modules folder in favor of a .pnp.js file.





 .pnp.js , , , Yarn . - node_modules, .





Yarn   node_modules,  , , .





, , , .





JavaScript Yarn Lerna .





, Yarn , , .





,

, Yarn 2 API, . β€”  yarn add



  yarn install



  !





Yarn, , Yarn   TypeScript,  @types/packages



  ,  yarn add



.





?

Yarn , .





Yarn, :





❯ npm install -g yarn
      
      



yarn --version



  -  1.22.x



), :





❯ mkdir my-app
❯ cd my-app
      
      



β€œBerry” β€” Yarn 2.

Yarn  my-app



:





❯ yarn set version berry
      
      



, !





, :





  • yarn init



    β€Š β€” β€Š





  • yarn add <package> [--dev]



    β€Š β€”β€Š





  • yarn remove <package>



    β€Š β€” β€Š





  • yarn up <package>



    β€Š β€”β€Š





, Yarn:





  • , , ;





  • ,  ;





  • .





React.js Yarn- TypeScript

, , , , Yarn .





, Yarn Berry .





package.json TypeScript:





❯ yarn init
❯ yarn plugin import typescript

      
      



React:





❯ yarn add react react-dom

➀ YN0000: β”Œ Resolution step
➀ YN0000: β”” Completed in 1s 932ms
➀ YN0000: β”Œ Fetch step
➀ YN0013: β”‚ loose-envify@npm:1.4.0
➀ YN0013: β”‚ object-assign@npm:4.1.1
➀ YN0013: β”‚ react-dom@npm:17.0.2
➀ YN0013: β”‚ react@npm:17.0.2
➀ YN0013: β”‚ scheduler@npm:0.20.2
➀ YN0000: β”” Completed in 0s 502ms
➀ YN0000: β”Œ Link step
➀ YN0000: β”” Completed
➀ YN0000: Done in 2s 503ms
      
      



@types/



!





package.json
package.json

What is the bottom line

The Yarn 1.x (Classic) branch has already officially moved into support status, which involves only fixing vulnerabilities.





All new features will be developed exclusively for Yarn 2, a version of which will be distributed through  yarn set version



.





If Yarn doesn’t make friends with your IDE, there are a few things to install . Don't be bored!








All Articles