Yarn (package manager)

Last updated
Yarn
Developer(s) Various
Initial release18 June 2016;7 years ago (2016-06-18) [1]
Stable release
4.1.1 [2]   OOjs UI icon edit-ltr-progressive.svg / 4 March 2024;2 months ago (4 March 2024)
Repository
Written in TypeScript, JavaScript
Platform Cross-platform
Type Package manager
License BSD 2-Clause License
Website yarnpkg.com OOjs UI icon edit-ltr-progressive.svg

Yarn is one of the main JavaScript package managers, [3] [4] developed 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]

Contents

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 in a single pass by running the installation command only once.

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

Syntax

To install yarn:

npm install -g yarn

To install a package with yarn: [8]

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 also

Related Research Articles

The Comprehensive Perl Archive Network (CPAN) is a repository of over 250,000 software modules and accompanying documentation for 39,000 distributions, written in the Perl programming language by over 12,000 contributors. CPAN can denote either the archive network or the Perl program that acts as an interface to the network and as an automated software installer. Most software on CPAN is free and open source software.

<span class="mw-page-title-main">Konqueror</span> Web browser and file manager

Konqueror is a free and open-source web browser and file manager that provides web access and file-viewer functionality for file systems. It forms a core part of the KDE Software Compilation. Developed by volunteers, Konqueror can run on most Unix-like operating systems. The KDE community licenses and distributes Konqueror under GNU GPL-2.0-or-later.

A JavaScript library is a library of pre-written JavaScript code that allows for easier development of JavaScript-based applications, especially for AJAX and other web-centric technologies. They can be included in a website by embedding it directly in the HTML via a script tag.

<span class="mw-page-title-main">Google Closure Tools</span> JavaScript developer toolkit

Google Closure Tools is a set of tools to help developers build rich web applications with JavaScript. It was developed by Google for use in their web applications such as Gmail, Google Docs and Google Maps. As of 2023, the project had over 230K LOCs not counting the embedded Mozilla Rhino compiler.

<span class="mw-page-title-main">Node.js</span> JavaScript runtime environment

Node.js is a cross-platform, open-source JavaScript runtime environment that can run on Windows, Linux, Unix, macOS, and more. Node.js runs on the V8 JavaScript engine, and executes JavaScript code outside a web browser.

npm JavaScript package manager

npm is a package manager for the JavaScript programming language maintained by npm, Inc., a subsidiary of GitHub. npm is the default package manager for the JavaScript runtime environment Node.js and is included as a recommended feature in the Node.js installer.

<span class="mw-page-title-main">Amber Smalltalk</span>

Amber Smalltalk, formerly named Jtalk, is an implementation of the programming language Smalltalk-80, that runs on the JavaScript runtime of a web browser. It is designed to enable client-side development using Smalltalk. The programming environment in Amber is named Helios.

Mustache is a web template system. Mustache is described as a logic-less system because it lacks any explicit control flow statements, like if and else conditionals or for loops; however, both looping and conditional evaluation can be achieved using section tags processing lists and anonymous functions (lambdas). It is named "Mustache" because of heavy use of braces, { }, that resemble a sideways moustache. Mustache is used mainly for mobile and web applications.

<span class="mw-page-title-main">Cloud9 IDE</span> Online integrated development environment

Cloud9 IDE is an Online IDE, published as open source from version 2.0, until version 3.0. It supports multiple programming languages, including C, C++, PHP, Ruby, Perl, Python, JavaScript with Node.js, and Go.

LuaRocks is a package manager for the Lua programming language that provides a standard format for distributing Lua modules, a tool designed to easily manage the installation of rocks, and a server for distributing them. While not included with the Lua distribution, it has been called the "de facto package manager for community-contributed Lua modules".

<span class="mw-page-title-main">Socket.IO</span> Library for realtime web applications

Socket.IO is an event-driven library for real-time web applications. It enables real-time, bi-directional communication between web clients and servers. It consists of two components: a client, and a server. Both components have a nearly identical API.

<span class="mw-page-title-main">Webpack</span> Open-source JavaScript module bundler

Webpack is a free and open-source module bundler for JavaScript. It is made primarily for JavaScript, but it can transform front-end assets such as HTML, CSS, and images if the corresponding loaders are included. Webpack takes modules with dependencies and generates static assets representing those modules.

NativeScript is an open-source framework to develop mobile apps on the iOS and Android platforms. It was originally conceived and developed by Progress. At the end of 2019 responsibility for the NativeScript project was taken over by long-time Progress partner, nStudio. In December 2020 nStudio also oversaw the induction of NativeScript into OpenJS Foundation as an Incubating Project. NativeScript apps are built using JavaScript, or by using any programming language that transpiles to JavaScript, such as TypeScript. NativeScript supports the Angular and Vue JavaScript frameworks. Mobile applications built with NativeScript result in fully native apps, which use the same APIs as if they were developed in Xcode or Android Studio. Additionally, software developers can re-purpose third-party libraries from CocoaPods, Maven, and npm.js in their mobile applications without the need for wrappers.

gulp is an open-source JavaScript toolkit, used as a streaming build system in front-end web development.

Grunt is a JavaScript task runner, a tool used to automatically perform frequent tasks such as minification, compilation, unit testing, and linting. It uses a command-line interface to run custom tasks defined in a file. Grunt was created by Ben Alman and is written in Node.js. It is distributed via npm. As of October 2022, there were more than 6,000 plugins available in the Grunt ecosystem.

<span class="mw-page-title-main">Hoodie (software)</span>

In computing, Hoodie is an open-source JavaScript package, that enables offline-first, front-end web development by providing a complete backend infrastructure. It aims to allow developers to rapidly develop web applications using only front-end code by providing a backend based on Node.js and Apache CouchDB. It runs on many Unix-like systems as well as on Microsoft Windows.

<span class="mw-page-title-main">Deno (software)</span> Secure JavaScript and TypeScript runtime

Deno is a runtime for JavaScript, TypeScript, and WebAssembly that is based on the V8 JavaScript engine and the Rust programming language. Deno was co-created by Ryan Dahl, who also created Node.js.

peacenotwar is a piece of malware, which has been characterized as protestware, created by Brandon Nozaki Miller. In March 2022, it was added as a dependency in an update for node-ipc, a common JavaScript dependency.

On March 22, 2016, Azer Koçulu, a software engineer, removed a package from npm he had published titled left-pad. Koçulu deleted the package following a dispute with Kik, in which the company forcibly took control of his package name kik. As a result, thousands of software projects that utilized left-pad as a dependency, including the Babel transcompiler and the React web framework, were unable to be built or installed.

References

  1. "Earliest releases of yarn". GitHub. Retrieved Jun 18, 2016.
  2. "Release v4.1.1".
  3. "Package management basics". MDN. 2022-09-28.
  4. "5 best JavaScript Package Managers". Dunebook.com. 2022-02-05.
  5. "Yarn: A new package manager for JavaScript". Engineering at Meta. 2016-10-11. Retrieved 2021-11-22.
  6. "Package Manager – NPM and Yarn Explained with Examples". Sitepoint. 2021-09-21.
  7. "How To Install and Use the Yarn Package Manager for Node.js". DigitalOcean. 2021-08-10.
  8. "Yarn vs npm: Everything You Need to Know". CodeSweetly. 2023-02-04.