Yarn is a
software packaging system developed in 2016 by Facebook (now
Meta
Meta (from the Greek μετά, '' meta'', meaning "after" or "beyond") is a prefix meaning "more comprehensive" or "transcending".
In modern nomenclature, ''meta''- can also serve as a prefix meaning self-referential, as a field of study or ende ...
) for the
Node.js
Node.js is an open-source server environment. Node.js is cross-platform and runs on Windows, Linux, Unix, and macOS. Node.js is a back-end JavaScript runtime environment. Node.js runs on the V8 JavaScript Engine and executes JavaScript code ou ...
JavaScript
JavaScript (), often abbreviated as JS, is a programming language that is one of the core technologies of the World Wide Web, alongside HTML and CSS. As of 2022, 98% of Website, websites use JavaScript on the Client (computing), client side ...
runtime environment. An alternative to the
npm NPM may stand for:
Organizations
* National Postal Museum (since 1993), a museum in Washington, D.C., United States
* National Palace Museum, a museum in Taipei, Taiwan
* npm, Inc., a software development and hosting company based in California, U ...
package manager, Yarn was created as a collaboration of Facebook,
Exponent
Exponentiation is a mathematical operation, written as , involving two numbers, the '' base'' and the ''exponent'' or ''power'' , and pronounced as " (raised) to the (power of) ". When is a positive integer, exponentiation corresponds to re ...
(now Expo.dev),
Google
Google LLC () is an American Multinational corporation, multinational technology company focusing on Search Engine, search engine technology, online advertising, cloud computing, software, computer software, quantum computing, e-commerce, ar ...
, and Tilde (the company behind
Ember.js
Ember.js is an open-source JavaScript web framework that utilizes a component-service pattern. It allows developers to create scalable single-page web applications by incorporating common idioms, best practices, and patterns from other single-pa ...
) to solve consistency, security, and performance problems with large codebases.
Functionality
Users can write their own plugins for Yarn.
Constraints
Yarn constraints allow users to enforce rules for their dependencies or manifest fields across scoped workspaces.
Offline cache
Downloaded packages are cached and stored as a single file.
Plug'n'Play
Plug'n'Play allows users to run Node projects without
node_modules
folder, defining the way or location to resolve dependencies package files with the Plug-n-Play-control file. This feature is aimed to fix an unwell structured
node_modules
architecture and resulting in a faster Node.js application start-up time.
Plugins
Plugins 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
yarn add
and
yarn install
'', which'' are also preinstalled plugins.
Protocols
Users 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 Workflow
Release Workflow automatically upgrades relative packages among monorepos workspaces when root packages are upgraded.
Workspaces
Workspaces 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 by only running
yarn install
once to install all of them in a single pass.
Zero-Installs
Zero-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
* Yarn can install packages from local cache.
* Yarn binds versions of the package strongly.
* Yarn uses checksum for ensuring data integrity, while npm uses SHA-512 to check data integrity of the packages downloaded.
* Yarn installs packages in parallel, while npm installs one package at a time.
See also
*
npm (software)
npm (Pseudo-acronym, originally short for Node Package Manager) is a package manager for the JavaScript programming language maintained by npm, Inc., npm, Inc. npm is the default package manager for the JavaScript runtime environment Node.js. I ...
*
Node.js
Node.js is an open-source server environment. Node.js is cross-platform and runs on Windows, Linux, Unix, and macOS. Node.js is a back-end JavaScript runtime environment. Node.js runs on the V8 JavaScript Engine and executes JavaScript code ou ...
References
{{Reflist
JavaScript programming tools
Package management systems