Modern Yarn projects expect the package manager version recorded in package.json, so the source you choose matters before the first install. To install Yarn on Debian with current Berry behavior, use Corepack with a Node.js package that actually ships the corepack command, then pin Yarn per project instead of relying on an old global Yarn Classic package.
The commands here cover Debian 13 (Trixie), Debian 12 (Bookworm), and Debian 11 (Bullseye). Debian’s own yarnpkg package is useful only as a Debian 13 fallback for Yarn Berry; Debian 12 and 11 still package Yarn Classic 1.x.
Install Yarn on Debian
Yarn has two active reader paths on Debian. Corepack follows Yarn’s current model for per-project version management, while Debian 13’s yarnpkg package gives you a distro-managed Yarn 4.x command named yarnpkg.
| Method | Source or Channel | Update Behavior | Best For | Trade-offs |
|---|---|---|---|---|
| Corepack with NodeSource Node.js 24.x | Yarn Corepack workflow with NodeSource APT packages | Node.js updates through APT; Yarn version is updated per project with yarn set version stable | Most projects that need current Yarn Berry behavior on Debian 13, 12, or 11 | Adds the NodeSource APT repository, but keeps Yarn version control aligned with upstream Yarn |
Debian yarnpkg package | Debian node-yarnpkg source package | Updates through Debian APT packages | Debian 13 systems that prefer distro-managed packages and can use yarnpkg | Debian 13 packages Yarn 4.1.0; Debian 12 and 11 package Yarn Classic 1.x instead |
Do not combine multiple Yarn install methods unless you deliberately want to compare them. A Corepack shim named
yarn, a manual symlink, and an npm-installed Yarn Classic binary can mask each other onPATH.
Install Yarn with Corepack and NodeSource
Corepack is the package-manager bridge used by current Yarn, but Debian’s default nodejs packages for Debian 13, 12, and 11 do not provide the corepack binary. The NodeSource 24.x package provides Node.js, npm, and Corepack from one APT-managed package, which makes it the most consistent path across the supported Debian releases.
If your account is not ready for administrative commands, set up sudo access first with the Debian sudoers guide. For a broader runtime comparison before choosing a Node.js source, use the dedicated Node.js on Debian installation guide.
Install the tools used to fetch and trust the NodeSource repository. The curl command downloads the signing key, while gpg converts the armored key into the binary keyring format APT expects here.
sudo apt update
sudo apt install curl gpg ca-certificates
sudo install -m 0755 -d /etc/apt/keyrings
Download the NodeSource signing key and save it as a dedicated APT keyring.
curl -fsSL https://deb.nodesource.com/gpgkey/nodesource-repo.gpg.key | sudo gpg --dearmor --yes -o /etc/apt/keyrings/nodesource.gpg
Create the NodeSource 24.x DEB822 source file. NodeSource publishes the 24.x packages through the nodistro suite. Its repository metadata advertises amd64, arm64, and armhf package indexes, but you should still confirm your host’s candidate with apt-cache policy nodejs before installing.
printf '%s\n' \
'Types: deb' \
'URIs: https://deb.nodesource.com/node_24.x' \
'Suites: nodistro' \
'Components: main' \
"Architectures: $(dpkg --print-architecture)" \
'Signed-By: /etc/apt/keyrings/nodesource.gpg' | sudo tee /etc/apt/sources.list.d/nodesource.sources > /dev/null
Refresh APT metadata and confirm the nodejs candidate comes from NodeSource before installing it.
sudo apt update
apt-cache policy nodejs
The policy output should show a candidate from https://deb.nodesource.com/node_24.x and the nodistro/main component. If APT still shows only Debian’s package, recheck the source file and keyring path before continuing.
If Debian’s
nodejs,npm,libnode-dev, or Node-dependent tools are already installed, read the APT transaction before accepting it. NodeSource’s unversionednodejspackage becomes the candidate while this source is enabled, so it can replace Debian-packaged Node.js components.
Install Node.js from the enabled NodeSource repository.
sudo apt install nodejs
Verify Node.js, npm, and Corepack. A current NodeSource 24.x install returns Node.js 24.x, npm 11.x, and Corepack 0.34.x.
node --version
npm --version
corepack --version
command -v corepack
Example output:
v24.x.x 11.x.x 0.34.x /usr/bin/corepack
Enable Corepack shims and install the current stable Yarn release as the global Corepack default.
sudo corepack enable
corepack install -g yarn@stable
Verify the Yarn command.
yarn --version
command -v yarn
The stable channel currently resolves to Yarn 4.14.1. Newer output is expected after Yarn publishes another stable release.
4.14.1 /usr/bin/yarn
Install Yarn from Debian Repositories on Debian 13
Debian 13 packages Yarn Berry as yarnpkg. This method is fully APT-managed, but it uses Debian’s packaged Yarn branch and command name rather than the upstream Corepack workflow. Use yarnpkg in APT commands; apt install yarn is not the Debian package path documented here.
Use this method only on Debian 13. Debian 12 and Debian 11 package
yarnpkgas Yarn Classic 1.x, so those releases should use the Corepack method for new Yarn Berry projects.
sudo apt update
sudo apt install yarnpkg
Check the packaged Yarn version.
yarnpkg --version
command -v yarnpkg
Debian 13 currently reports:
4.1.0 /usr/bin/yarnpkg
The package command is yarnpkg, not yarn. If you want the common yarn command name, create a symlink only when that path is unused.
if [ -e /usr/local/bin/yarn ] || [ -L /usr/local/bin/yarn ]; then
ls -l /usr/local/bin/yarn
else
sudo ln -s /usr/bin/yarnpkg /usr/local/bin/yarn
fi
Confirm the symlink resolves to the packaged Yarn command.
yarn --version
command -v yarn
Use Yarn Berry on Debian
Corepack and Yarn Berry work best when each project declares the package manager it expects. That keeps team members, CI jobs, and deployment hosts on the same Yarn release. For deeper command coverage beyond these common workflows, use the official Yarn CLI reference.
The examples in this section use
yarn. If you installed Debian 13’syarnpkgpackage and did not create the optional symlink, replaceyarnwithyarnpkg.
Initialize a Yarn Project
Create a new Yarn Berry project in the current directory.
yarn init -2
The project manifest should include a packageManager field similar to this example.
{
"name": "my-project",
"packageManager": "yarn@4.14.1"
}
Set the Yarn Version for a Project
Use the stable channel when a project should follow the latest production Yarn release.
yarn set version stable
yarn install
Use an exact version when a project needs reproducible tooling during a migration or release freeze.
yarn set version 4.14.1
yarn install
Corepack can represent normal stable releases through the packageManager field. If a project already has yarnPath configured, Yarn may also store a release file under .yarn/releases/.
Avoid manually downloading versioned Yarn .cjs files from search results. Use yarn set version stable or an exact version command so Yarn resolves the release, updates the project metadata, and keeps the recorded package manager consistent.
Install and Manage Dependencies
Add runtime dependencies with yarn add and development-only dependencies with -D.
yarn add lodash
yarn add -D eslint
Install dependencies from an existing project lockfile.
yarn install
Remove a dependency from the project.
yarn remove lodash
Update Dependencies
Yarn Berry uses yarn up for dependency upgrades. Use an explicit package name for one dependency or an interactive review when you want to inspect choices before applying them.
yarn up lodash
yarn up --interactive
Update all dependencies with a quoted wildcard so the shell does not expand it before Yarn receives the pattern.
yarn up '*'
Run Scripts and Temporary CLIs
Run scripts defined in package.json with the explicit run form or the short script name.
yarn run build
yarn test
Use yarn dlx for one-off tools that should run in a temporary environment rather than become permanent project dependencies.
yarn dlx create-vite my-app
yarn dlxis not a replacement for dependencies your project must reproduce later. Useyarn addoryarn add -Dwhen the package belongs in the lockfile.
Run Workspace Commands
Yarn workspaces let one repository manage several related packages. List the detected workspaces from the repository root before running targeted workspace commands.
yarn workspaces list
Run a script in one workspace by naming the workspace from its package.json.
yarn workspace my-package run build
Run the same script across all workspaces with workspaces foreach. The -A option selects all workspaces, which keeps the command explicit on current Yarn Berry releases.
yarn workspaces foreach -A run build
Switch Plug’n’Play and node_modules Modes
Yarn Berry defaults to Plug’n’Play in many projects, which resolves dependencies through .pnp.cjs instead of a traditional node_modules tree. Some older tools still expect node_modules, so keep the linker setting project-specific.
yarn config set nodeLinker node-modules
yarn install
Switch back to Plug’n’Play when the project supports it.
yarn config set nodeLinker pnp
yarn install
Update Yarn on Debian
Update ownership depends on the install method. NodeSource owns the Node.js and Corepack package, while Yarn itself is normally pinned inside each project.
Update Corepack and Yarn from the NodeSource Method
Update the NodeSource-managed Node.js package through APT.
sudo apt update
sudo apt install --only-upgrade nodejs
Refresh the global Corepack default for new projects, then update each existing project from inside that project directory.
corepack install -g yarn@stable
yarn set version stable
yarn install
Update Debian Repository Yarn
For the Debian 13 yarnpkg package, use a normal targeted APT upgrade.
sudo apt update
sudo apt install --only-upgrade yarnpkg
Troubleshoot Yarn on Debian
corepack: command not found
This error usually means the active Node.js package does not include Corepack. Debian’s default nodejs packages for Debian 13, 12, and 11 do not ship a corepack command.
node --version
command -v node
command -v corepack
If command -v corepack prints nothing, install Node.js from the NodeSource 24.x method or install Corepack through npm only after confirming the Node.js runtime is new enough for the Yarn version you need.
error Command “dlx” not found
The dlx command belongs to Yarn Berry. This error commonly appears when the shell is running Yarn Classic 1.x from Debian 11 or 12, an older npm global install, or another earlier yarn binary on PATH.
yarn --version
command -v yarn
If the version starts with 1., remove or bypass the Classic binary and use the Corepack method. If you installed Debian 13’s package, run yarnpkg dlx or create the guarded symlink from the Debian repository method.
npm install -g yarn Installed Yarn Classic
The npm package named yarn tracks Yarn Classic 1.22.x. For Yarn Berry, remove the global npm package and let Corepack manage Yarn.
npm uninstall -g yarn
sudo corepack enable
corepack install -g yarn@stable
yarn --version
APT Still Uses Debian’s Node.js Package
If apt-cache policy nodejs does not show NodeSource as the candidate after adding the repository, inspect the source file and refresh APT metadata.
sudo sed -n '1,20p' /etc/apt/sources.list.d/nodesource.sources
sudo apt update
apt-cache policy nodejs
Systems with older NodeSource setup scripts may still have a legacy nodesource.list file. Disable the old file only after confirming the DEB822 nodesource.sources file is correct.
if [ -f /etc/apt/sources.list.d/nodesource.list ]; then
sudo mv /etc/apt/sources.list.d/nodesource.list /etc/apt/sources.list.d/nodesource.list.disabled
fi
sudo apt update
Plug’n’Play Module Errors
Some older tools still assume dependencies live under node_modules. The common symptom is a module resolution error even though yarn install completed.
Error: Cannot find module 'some-package'
Switch only that project to the traditional linker and reinstall dependencies.
yarn config set nodeLinker node-modules
yarn install
yarn config get nodeLinker
The final command should print:
node-modules
Remove Yarn from Debian
Use the removal path that matches the install method. Keep Node.js installed if other projects, build tools, or services on the system still depend on it.
Remove the Corepack and NodeSource Method
Disable the Yarn shim first. This removes the command Corepack placed on the system path.
sudo corepack disable yarn
hash -r
command -v yarn || true
If NodeSource Node.js was installed only for Yarn, remove the package and then remove the source created earlier. Remove the keyring only when no remaining APT source still references it.
sudo apt remove nodejs
sudo rm -f /etc/apt/sources.list.d/nodesource.sources
source_paths=()
[ -f /etc/apt/sources.list ] && source_paths+=(/etc/apt/sources.list)
[ -d /etc/apt/sources.list.d ] && source_paths+=(/etc/apt/sources.list.d)
if [ "${#source_paths[@]}" -gt 0 ] && grep -Rsl -- '/etc/apt/keyrings/nodesource.gpg' "${source_paths[@]}"; then
printf 'Keeping /etc/apt/keyrings/nodesource.gpg because another source still references it.\n'
else
sudo rm -f /etc/apt/keyrings/nodesource.gpg
fi
sudo apt update
Check that the nodejs package is no longer installed when you chose to remove it.
dpkg-query -W -f='${db:Status-Abbrev} ${binary:Package}\n' nodejs 2>/dev/null || true
No line beginning with ii should appear after package removal.
Confirm NodeSource no longer contributes the active nodejs candidate.
apt-cache policy nodejs
Remove Debian Repository Yarn
Remove the Debian package and delete the optional /usr/local/bin/yarn symlink only if you created it for the yarnpkg package.
sudo apt remove yarnpkg
if [ "$(readlink /usr/local/bin/yarn 2>/dev/null)" = "/usr/bin/yarnpkg" ]; then
sudo rm -f /usr/local/bin/yarn
fi
hash -r
Check that the Debian package is no longer installed.
dpkg-query -W -f='${db:Status-Abbrev} ${binary:Package}\n' yarnpkg 2>/dev/null || true
No line beginning with ii should appear after removal.
Remove User-Level Yarn and Corepack Cache
Yarn projects may keep project-local files such as .yarn/, .yarnrc.yml, and yarn.lock. The cleanup here targets only user-level Yarn and Corepack state in your home directory.
for path in "$HOME/.yarn" "$HOME/.yarnrc.yml" "$HOME/.cache/node/corepack"; do
[ -e "$path" ] && printf '%s\n' "$path"
done
The cleanup command permanently deletes user-level Yarn configuration and Corepack’s cached package-manager releases for your account. Back up anything you still need before running it.
rm -rf "$HOME/.yarn" "$HOME/.yarnrc.yml" "$HOME/.cache/node/corepack"
Conclusion
Yarn is available on Debian with Corepack managing the current stable Berry release, or through Debian 13’s distro-managed yarnpkg package when that trade-off fits better. From here, add Git on Debian for source control, use Visual Studio Code on Debian for editor integration, or add Docker on Debian for containerized JavaScript builds.


Formatting tips for your comment
You can use basic HTML to format your comment. Useful tags currently allowed in published comments:
<code>command</code>command<strong>bold</strong><em>italic</em><blockquote>quote</blockquote>