Yarn (package manager)
Yarn is one of the main JavaScript package managers,[3][4] initially started in 2016 by Sebastian McKenzie of Meta (formerly Facebook) for the Node.js JavaScript runtime environment. An alternative to the npm package manager, Yarn was created as a collaboration of Facebook (now Meta), Exponent (now Expo.dev), Google, and Tilde (the company behind Ember.js) to solve consistency, security, and performance problems with large codebases.[5] While bootstrapped by tech companies, the project was setup from the get go as its own GitHub organization, and eventually became fully autonomous in 2019, following its lead maintainer as he left Facebook for Datadog. Yarn 2 & Yarn Plug'n'PlayIn 2020 the Yarn team released a major update, Yarn 2.0, also codenamed "Berry".[6] This version came with a full rewriting of both the codebase (which migrated to TypeScript in the process) and test suite. Many features were introduced, a cleaving one being a new unique installation strategy called Yarn Plug'n'Play. Under this default but optional mode, Yarn wouldn't generate a PluginsUsers can write their own plugins for Yarn. ConstraintsYarn constraints allow users to enforce rules for their dependencies or manifest fields across scoped workspaces. Offline cacheDownloaded packages are cached and stored as a single file. Plug'n'PlayPlug'n'Play allows users to run Node projects without PluginsPlugins can add new resolvers, fetchers, linkers, commands, and can also register to some events or be integrated with each other, most features of Yarn are implemented through plugins, including ProtocolsUsers can define which protocol will be used to resolve certain packages, for example, the git protocol is used for downloading a public package from a Git repository, and the patch protocol is used for creating a patched copy of the original package. Release WorkflowRelease Workflow automatically upgrades relative packages among monorepos workspaces when root packages are upgraded. WorkspacesWorkspaces allow multiple projects to work together in the same repository and automatically apply changes to other relatives when source code is modified, allowing installation of multiple packages in a single pass by running the installation command only once. Zero-InstallsZero-Installs solve the needs of installation of packages when packages is required to install when the codes is just fresh fetched to local. Comparison to npm
SyntaxTo install yarn: npm install -g yarn To install a package with yarn:[10] yarn add package-name To install a package with yarn for development and testing purposes: yarn add package-name --dev NB: in the first versions, it was: yarn install package-name --save-dev See alsoReferences
External links |