Skip to content

/codes/yarn/yarn-error-codes

Yarn error codes YN0000 – YN0092: what YN0028, YN0002, YN0060 and the others mean

verified onenvironmentlocal · windows 10.0.26200 arm64 · GNU bash 5.3.15 (Git Bash)updated
tool
Yarn
versions
Yarn 2 – 4
os
any

Yarn 2 and later (Berry) prefix every install message with a code such as ➤ YN0028: │. The code identifies the kind of message, so you can search for it or silence it: YN0000 is a plain informational line, YN0028 means the lockfile would change under --immutable, YN0002 and YN0060 are peer dependency problems, and YN0009 means a package's build script failed. Yarn 1 (Classic) does not use these codes.

Two codes in real output

bash
cat > package.json <<'EOF'
{ "name": "app", "version": "1.0.0", "license": "MIT", "dependencies": { "is-number": "7.0.0" } }
EOF
touch yarn.lock
npx --yes @yarnpkg/cli-dist@4 install > /dev/null 2>&1
echo "--- dependency added, install --immutable"
cat > package.json <<'EOF'
{ "name": "app", "version": "1.0.0", "license": "MIT", "dependencies": { "is-number": "7.0.0", "is-odd": "3.0.1" } }
EOF
npx --yes @yarnpkg/cli-dist@4 install --immutable 2>&1 | grep "explicitly forbidden"
echo "--- package that does not exist"
cat > package.json <<'EOF'
{ "name": "app", "version": "1.0.0", "license": "MIT", "dependencies": { "no-such-pkg-errcodex-zz": "1.0.0" } }
EOF
npx --yes @yarnpkg/cli-dist@4 install 2>&1 | grep "Package not found"

Output

--- dependency added, install --immutable
➤ YN0028: │ The lockfile would have been modified by this install, which is explicitly forbidden.
--- package that does not exist
➤ YN0035: │ no-such-pkg-errcodex-zz@npm:1.0.0: Package not found

The 404 from the registry is reported as YN0035, a code the documentation table does not list (the docs skip YN0033 to YN0045).

The codes you will meet most

CodeNameMeaning and fix
YN0000UNNAMEDInformational line without a specific code; read the text
YN0001EXCEPTIONUnexpected error inside Yarn; the message has the stack trace
YN0002MISSING_PEER_DEPENDENCYA package needs a peer dependency you did not add; add it to package.json
YN0007MUST_BUILDA package has a postinstall script that will run
YN0009BUILD_FAILEDA package build script failed; the log path is printed next to it
YN0013FETCH_NOT_CACHEDPackage downloaded because it was not in the cache (informational)
YN0018CACHE_CHECKSUM_MISMATCHA cached archive differs from the lockfile checksum; clear the cache or check the registry
YN0020MISSING_LOCKFILE_ENTRYyarn.lock lacks an entry for a dependency; run yarn install
YN0028FROZEN_LOCKFILE_EXCEPTIONThe lockfile would be modified under --immutable (CI); run yarn install locally and commit
YN0032NODE_GYP_INJECTEDnode-gyp was added implicitly for a native package; declare it explicitly
YN0050DEPRECATED_CLI_SETTINGSA CLI flag is deprecated; use the replacement Yarn names
YN0060INCOMPATIBLE_PEER_DEPENDENCYThe installed peer does not satisfy the requested range
YN0061DEPRECATED_PACKAGEThe registry marks this package version as deprecated
YN0062INCOMPATIBLE_OSOptional package skipped because of its "os" field
YN0063INCOMPATIBLE_CPUOptional package skipped because of its "cpu" field
YN0076INCOMPATIBLE_ARCHITECTUREPackage skipped for this OS/CPU/libc combination
YN0080NETWORK_DISABLEDNetwork access is disabled (enableNetwork: false) but a download was needed
YN0081NETWORK_UNSAFE_HTTPAn http:// registry is blocked; use https or unsafeHttpWhitelist
YN0082RESOLUTION_FAILEDNo version matches the requested range
YN0086EXPLAIN_PEER_DEPENDENCIES_CTASummary of peer warnings; run yarn explain peer-requirements HASH

Silencing or upgrading a code

Codes can be filtered in .yarnrc.yml with logFilters, for example to hide deprecation notices or turn a warning into an error:

.yarnrc.yml
logFilters:
  - code: YN0061
    level: discard
  - code: YN0060
    level: error

yarn explain YN0028 prints the documentation for a code in the terminal.

Sources