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
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
| Code | Name | Meaning and fix |
|---|---|---|
| YN0000 | UNNAMED | Informational line without a specific code; read the text |
| YN0001 | EXCEPTION | Unexpected error inside Yarn; the message has the stack trace |
| YN0002 | MISSING_PEER_DEPENDENCY | A package needs a peer dependency you did not add; add it to package.json |
| YN0007 | MUST_BUILD | A package has a postinstall script that will run |
| YN0009 | BUILD_FAILED | A package build script failed; the log path is printed next to it |
| YN0013 | FETCH_NOT_CACHED | Package downloaded because it was not in the cache (informational) |
| YN0018 | CACHE_CHECKSUM_MISMATCH | A cached archive differs from the lockfile checksum; clear the cache or check the registry |
| YN0020 | MISSING_LOCKFILE_ENTRY | yarn.lock lacks an entry for a dependency; run yarn install |
| YN0028 | FROZEN_LOCKFILE_EXCEPTION | The lockfile would be modified under --immutable (CI); run yarn install locally and commit |
| YN0032 | NODE_GYP_INJECTED | node-gyp was added implicitly for a native package; declare it explicitly |
| YN0050 | DEPRECATED_CLI_SETTINGS | A CLI flag is deprecated; use the replacement Yarn names |
| YN0060 | INCOMPATIBLE_PEER_DEPENDENCY | The installed peer does not satisfy the requested range |
| YN0061 | DEPRECATED_PACKAGE | The registry marks this package version as deprecated |
| YN0062 | INCOMPATIBLE_OS | Optional package skipped because of its "os" field |
| YN0063 | INCOMPATIBLE_CPU | Optional package skipped because of its "cpu" field |
| YN0076 | INCOMPATIBLE_ARCHITECTURE | Package skipped for this OS/CPU/libc combination |
| YN0080 | NETWORK_DISABLED | Network access is disabled (enableNetwork: false) but a download was needed |
| YN0081 | NETWORK_UNSAFE_HTTP | An http:// registry is blocked; use https or unsafeHttpWhitelist |
| YN0082 | RESOLUTION_FAILED | No version matches the requested range |
| YN0086 | EXPLAIN_PEER_DEPENDENCIES_CTA | Summary 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:
logFilters:
- code: YN0061
level: discard
- code: YN0060
level: erroryarn explain YN0028 prints the documentation for a code in the terminal.
Sources
Related pages
flags · yarnyarn install --frozen-lockfile (Yarn 1) and --immutable (Yarn 2+)yarn install --frozen-lockfile fails instead of updating yarn.lock when it is out of date; Yarn 2+ uses --immutable. Real errors and the lockfile fix.compare · yarnYarn 1 (Classic) vs Yarn 4 (Berry): differences and command mappingYarn 1 is in maintenance mode; Yarn 2+ (Berry) adds Plug'n'Play, .yarnrc.yml, Corepack pinning and renamed commands. What changes, plus a command map.glossary · npmWhat is a peer dependency in npm?A peer dependency is a package a library expects the host project to provide, like react for react-dom. npm 7+ installs peers automatically and checks ranges.