# 使用 Homebrew, apk, chocolatey, MacPorts, Nix, pacman, zypper, scoop, winget, apt, dnf 安装 yarn

查看 yarn 的安装路径、可执行文件、元数据以及面向 AI 代理工作流的安全说明。

## 安装

```sh
sudo av install brew:yarn
```

## 代理安全回答

yarn manages JavaScript dependencies and package scripts with registry access.

- **凭据访问:** Reads npm/yarn registry tokens, environment variables, and package scripts.
- **远程变更:** Can install packages and run scripts that modify remote systems.
- **发布/制品风险:** Can publish packages and build release artifacts.
- **推荐控制:** Gate publish, install scripts, and credentialed registry operations.
- **代理使用指南:** Allow local test/build after scan; require approval for publish and lifecycle scripts.

其他安装命令:

### macOS

- Homebrew (100%):

```sh
brew install yarn
```

  证据: local Homebrew formula metadata

- MacPorts (94%):

```sh
sudo port install yarn
```

  证据: MacPorts ports tree: devel/yarn/Portfile from https://api.github.com/repos/macports/macports-ports/git/trees/master?recursive=1

### Linux

- apk (92%):

```sh
sudo apk add yarn
```

  证据: Alpine Linux edge package indexes: yarn from https://dl-cdn.alpinelinux.org/alpine/edge/community/x86_64/APKINDEX.tar.gz

- Nix (92%):

```sh
nix profile install nixpkgs#yarn
```

  证据: nixpkgs package indexes: pkgs/by-name/ya/yarn/package.nix from https://api.github.com/repos/NixOS/nixpkgs/git/trees/master?recursive=1

- pacman (92%):

```sh
sudo pacman -S yarn
```

  证据: Arch Linux sync databases: yarn from https://geo.mirror.pkgbuild.com/extra/os/x86_64/extra.db.tar.gz

- zypper (92%):

```sh
sudo zypper install yarn
```

  证据: openSUSE Tumbleweed package metadata: yarn from https://download.opensuse.org/tumbleweed/repo/oss/repodata/50b07339cb64c8ed4091bdbabddadc1ff5737b090e478818a195b40d8a3292861a879139b4a3987c31109699fde9fbf4a716367ddf4eef77da75f96e3193d6ed-primary.xml.zst

- Debian apt (92%):

```sh
sudo apt install yarnpkg
```

  证据: Debian stable package indexes: yarnpkg from https://deb.debian.org/debian/dists/stable/main/binary-amd64/Packages.xz

- dnf (92%):

```sh
sudo dnf install yarnpkg
```

  证据: Fedora Rawhide package metadata: yarnpkg from https://dl.fedoraproject.org/pub/fedora/linux/development/rawhide/Everything/x86_64/os/repodata/07190dc5ae9f35ae73866675fed6d95fe6e8d9fe22c9d7cdf85862cb2ed24a4c-primary.xml.zst

### Windows

- Chocolatey (92%):

```sh
choco install yarn
```

  证据: Chocolatey community package catalog: yarn from http://community.chocolatey.org/api/v2/Packages?$filter=IsLatestVersion&$select=Id&$top=1000&$skiptoken='11','wsl-ubuntu-2204'

- Scoop (92%):

```sh
scoop install main/yarn
```

  证据: Scoop official bucket manifest trees: bucket/yarn.json from https://api.github.com/repos/ScoopInstaller/Main/git/trees/master?recursive=1

- winget (92%):

```sh
winget install --id Yarn.Yarn -e
```

  证据: Windows Package Manager source index: Yarn.Yarn from https://cdn.winget.microsoft.com/cache/source.msix

## 软件包事实

- **软件包键:** brew:yarn
- **软件包管理器:** Homebrew
- **版本:** 1.22.22
- **来源摘要:** JavaScript package manager
- **主页:** <https://yarnpkg.com/>
- **仓库:** <https://github.com/yarnpkg/yarn>
- **最后更新:** 2026-07-04T13:13:45+09:00
- **已生成:** 2026-08-03T19:37:03+00:00

## 可执行文件

- yarn (别名)
- yarnpkg (别名)

## 安装行为

- Bottle: 不可用

## 版本和新鲜度

- 页面生成时间: 2026-08-03
- 管理器版本: 1.22.22
## 项目历史与用法

Yarn is a JavaScript package manager created to make npm-registry installs faster, more reliable, and more reproducible. The Homebrew `yarn` package points at the classic 1.x line, but the project history continues through Yarn Berry and modern Yarn releases.

### 项目历史

Yarn was open-sourced on 2016-10-11 as a collaboration between Facebook, Exponent, Google, and Tilde. The launch post emphasized continued access to the npm registry while improving speed, consistency across machines, and secure offline operation.

The 1.x line established the features that made Yarn famous: a lockfile, deterministic installs, a global cache, offline mode, checksums, concurrency, and workspace-oriented workflows. The classic repository README now says the 1.x codebase is frozen except for historical upkeep and occasional hotfixes.

Modern Yarn moved to the yarnpkg/berry repository, created in 2018. Yarn 2.0 shipped on 2020-01-24 after a year of intensive development, bringing a TypeScript codebase, plugin architecture, Plug'n'Play, workspace-aware commands, a YAML lockfile/config model, and a different release and migration story from classic Yarn. Yarn 4.0 followed in 2023 after a long release-candidate cycle focused on reducing migration pain and improving user experience.

### 采用历史

Yarn's adoption was fast because it solved immediate pain in large JavaScript dependency trees: slow installs, non-determinism, network fragility, and inconsistent environments. It did not replace the npm registry; it competed at the client and workflow layer while consuming the same package ecosystem.

Classic Yarn became common in CI systems, monorepos, front-end applications, and open-source JavaScript projects. Later Yarn adoption split into two cultures: projects staying on stable 1.22.x for node_modules compatibility and projects moving to Berry for Plug'n'Play, constraints, plugins, workspaces, and zero-install workflows.

### 使用方式

Typical classic workflows are `yarn install`, `yarn add`, `yarn remove`, `yarn upgrade`, and `yarn run`, with `yarn.lock` committed so dependency resolution is reproducible. Workspaces let monorepos manage multiple packages in a single install graph.

Modern Yarn expands that usage into project management: `yarn set version`, plugins, constraints, workspace foreach commands, patch protocols, portable script execution, and selectable install strategies including node_modules and Plug'n'Play.

### 为什么软件包爱好者会关心

Yarn is one of the defining package-manager projects of the 2010s because it forced JavaScript tooling to treat reproducibility, lockfiles, cache behavior, and CI determinism as first-class package-manager features. Its competition with npm changed expectations for every JavaScript dependency client that followed.

For package nerds, Yarn is also a rare case where the package manager itself has two living historical identities: Yarn Classic as the widely packaged 1.x executable and Yarn Berry/Modern as the active architecture with plugins, PnP, and project-management features.

### 时间线

- 2016-01-19: yarnpkg/yarn repository is created on GitHub.
- 2016-10-11: Yarn is announced as a Facebook, Exponent, Google, and Tilde collaboration.
- 2016-10-18: GitHub release v0.16.0 is published shortly after launch.
- 2018-09-10: yarnpkg/berry repository is created for the modern Yarn line.
- 2020-01-24: Yarn 2.0 is released after 365 days of development.
- 2023-10-23: Yarn 4.0 is announced after 53 release candidates.
- 2024-03-09: Yarn Classic v1.22.22 is published.

### Related projects

- npm is the registry and original package-manager client Yarn was designed to interoperate with and improve upon.
- yarnpkg/berry is the active modern Yarn repository.
- Bundler and Cargo are named by the classic README as prior art.

### 来源

- <https://api.github.com/repos/yarnpkg/berry>
- <https://api.github.com/repos/yarnpkg/yarn>
- <https://api.github.com/repos/yarnpkg/yarn/releases?per_page=100>
- <https://classic.yarnpkg.com/blog/2016/10/11/introducing-yarn/>
- <https://github.com/yarnpkg/berry>
- <https://github.com/yarnpkg/yarn>
- <https://raw.githubusercontent.com/yarnpkg/berry/master/README.md>
- <https://raw.githubusercontent.com/yarnpkg/yarn/master/README.md>
- <https://yarnpkg.com/blog/release/2.0>
- <https://yarnpkg.com/blog/release/4.0>
- <https://yarnpkg.com/migration/overview>


## 安全说明

package manager and supply-chain mutator.

- **Geiger 风险:** orange / 高
- package manager and supply-chain mutator


## Configuration and credential file locations

These source-backed paths show where this package keeps local settings or durable credentials. Automic Vault can use them as review targets for secret scanning, migration, and command approval.


## Configuration files

- Unix: .yarnrc
## 其他软件包管理器记录

- Nix - yarn: normalized package name match | nixpkgs package indexes: pkgs/by-name/ya/yarn/package.nix from https://api.github.com/repos/NixOS/nixpkgs/git/trees/master?recursive=1
- apk - yarn - 1.22.22-r1: normalized package name match | Alpine Linux edge package indexes: yarn from https://dl-cdn.alpinelinux.org/alpine/edge/community/x86_64/APKINDEX.tar.gz | Fast, reliable, and secure dependency management for Node.js | https://classic.yarnpkg.com/
- pacman - yarn - 1.22.22-2: normalized package name match | Arch Linux sync databases: yarn from https://geo.mirror.pkgbuild.com/extra/os/x86_64/extra.db.tar.gz | Fast, reliable, and secure dependency management | https://classic.yarnpkg.com/
- zypper - yarn - 1.22.22-1.5: normalized package name match | openSUSE Tumbleweed package metadata: yarn from https://download.opensuse.org/tumbleweed/repo/oss/repodata/50b07339cb64c8ed4091bdbabddadc1ff5737b090e478818a195b40d8a3292861a879139b4a3987c31109699fde9fbf4a716367ddf4eef77da75f96e3193d6ed-primary.xml.zst | 📦🐈 Fast, reliable, and secure dependency management | https://github.com/yarnpkg/yarn/releases
- MacPorts - yarn: normalized package name match | MacPorts ports tree: devel/yarn/Portfile from https://api.github.com/repos/macports/macports-ports/git/trees/master?recursive=1
- Chocolatey - yarn: normalized package name match | Chocolatey community package catalog: yarn from http://community.chocolatey.org/api/v2/Packages?$filter=IsLatestVersion&$select=Id&$top=1000&$skiptoken='11','wsl-ubuntu-2204'
- Scoop - main/yarn: normalized package name match | Scoop official bucket manifest trees: bucket/yarn.json from https://api.github.com/repos/ScoopInstaller/Main/git/trees/master?recursive=1
- winget - Yarn.Yarn: normalized package name match | Windows Package Manager source index: Yarn.Yarn from https://cdn.winget.microsoft.com/cache/source.msix
- Debian apt - yarnpkg - 4.1.0+dfsg-1: installed executable or alias match | Debian stable package indexes: yarnpkg from https://deb.debian.org/debian/dists/stable/main/binary-amd64/Packages.xz | Fast, reliable, and secure dependency management | https://github.com/yarnpkg/berry
- Ubuntu apt - yarnpkg - 1.22.19+~cs24.27.18-4: installed executable or alias match | Ubuntu 24.04 LTS package indexes: yarnpkg from https://archive.ubuntu.com/ubuntu/dists/noble/universe/binary-amd64/Packages.gz | Fast, reliable and secure npm alternative | https://github.com/yarnpkg/yarn
- dnf - yarnpkg - 1.22.22-19.fc45: installed executable or alias match | Fedora Rawhide package metadata: yarnpkg from https://dl.fedoraproject.org/pub/fedora/linux/development/rawhide/Everything/x86_64/os/repodata/07190dc5ae9f35ae73866675fed6d95fe6e8d9fe22c9d7cdf85862cb2ed24a4c-primary.xml.zst | Fast, reliable, and secure dependency management. | https://github.com/yarnpkg/yarn


## Combined YAML source

View the package source record on GitHub. [combined/yarn.yml](https://github.com/mxcl/pkgdb/blob/main/combined/yarn.yml)


## 来源

- pkg.so package database
- Geiger risk classifier
- curated configuration and credential file locations
- curated package history
- pkgdb category and tag curation
- external package-manager database matches
- cross-ecosystem install command graph
- curated agent safety answer
