Skip to content

/errors/yarn/package-not-present-in-lockfile

Yarn: This package doesn't seem to be present in your lockfile; run "yarn install" to update the lockfile

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

Internal Error: app@workspace:.: This package doesn't seem to be present in your lockfile; run "yarn install" to update the lockfile means Yarn 2 or later (Berry) needed the dependency tree, but yarn.lock has no entry for the package named at the start (here the root workspace app@workspace:.). The lockfile is missing or older than package.json. Run yarn install to update it, then commit yarn.lock.

Reproduce it

bash
cat > package.json <<'EOF'
{ "name": "app", "scripts": { "hello": "node -e \"console.log('hi')\"" }, "dependencies": { "is-number": "7.0.0" } }
EOF
touch yarn.lock
npx --yes @yarnpkg/cli-dist@4 run hello 2>&1 | head -1
exit "${PIPESTATUS[0]}"

Output · exit 1

Internal Error: app@workspace:.: This package doesn't seem to be present in your lockfile; run "yarn install" to update the lockfile

The message is labelled Internal Error and followed by a stack trace from Yarn's own code, but it is not a Yarn bug: the cause is the stale lockfile.

Fix

bash
cat > package.json <<'EOF'
{ "name": "app", "scripts": { "hello": "node -e \"console.log('hi')\"" }, "dependencies": { "is-number": "7.0.0" } }
EOF
touch yarn.lock
npx --yes @yarnpkg/cli-dist@4 install >/dev/null
npx --yes @yarnpkg/cli-dist@4 run hello

Output

hi

In CI, Yarn enables immutable installs, so yarn install fails with YN0028: The lockfile would have been modified by this install, which is explicitly forbidden. instead of fixing the lockfile. Run yarn install locally and commit the result.

Sources