Yarn warns that package-lock.json exists next to yarn.lock
warning package-lock.json found. Your project contains lock files generated by tools other than Yarn.Short answer
Yarn 1 checks the project folder for package-lock.json and npm-shrinkwrap.json on every install and warns when it finds either. The warning only goes away when the file does. Pick one tool: convert the versions with yarn import if yarn.lock is missing, delete the npm file, and pin the package manager so nobody runs npm by accident.
Fix it fast
1Find out which cause you have
List which lock files the project has and which of them Git tracks. The warning names the file it found, and this shows whether yarn.lock is there as well.
yarn --version ls -1 package-lock.json npm-shrinkwrap.json yarn.lock 2>/dev/null git ls-files | grep -E '(^|/)(package-lock\.json|npm-shrinkwrap\.json|yarn\.lock)$'2Match what you see, then jump to its fix
- 1
The warning text says package-lock.json found, and both package-lock.json and yarn.lock are in the folder (or only package-lock.json is)A leftover package-lock.json from before the project moved to YarnFix - 2
You deleted package-lock.json, committed, and it came back after a teammate's install, a CI step, a Dockerfile or an editor buttonSomeone still runs npm in the project and it writes package-lock.json againFix - 3
npm-shrinkwrap.json found. This will not be updated or respected.npm-shrinkwrap.json is in the project, which gives a different warningFix
- 1
What does the error look like?
warning package-lock.json found. Your project contains lock files generated by tools other than Yarn.It is advised not to mix package managers in order to avoid resolution inconsistencies caused by unsynchronized lock files.To clear this warning, remove package-lock.json.warning npm-shrinkwrap.json found. This will not be updated or respected.
Cause 1 of 3
A leftover package-lock.json from before the project moved to Yarn
1Check
Yarn looks in the lockfile folder for an npm lock file on every install and prints this warning if it exists. Nothing else triggers it, so the file itself is the whole problem.
ls -l package-lock.json yarn.lock
grep -m1 lockfileVersion package-lock.json2Fix
If yarn.lock already exists, delete package-lock.json and commit that. If there is no yarn.lock yet, let Yarn build one from the npm lock file first (supported since Yarn 1.7), so the resolved versions carry over, and delete the npm file afterwards. When Yarn 1 stops with the corrupted-source message, the npm file is probably in npm's newest format (lockfileVersion 3, the default for new lock files). Rewrite it as version 2, which keeps the same versions, and import again.
# only when yarn.lock does not exist yet
yarn import
# if that ends with "Failed to import from package-lock.json, source file(s) corrupted"
npm install --package-lock-only --lockfile-version=2
yarn import
# then, in all cases
git rm package-lock.json3Verify
Run the install again. The warning must be gone and yarn.lock must be the only lock file Git tracks.
yarn install
git ls-files | grep -i lockConfirmed by classic.yarnpkg.com
Cause 2 of 3
Someone still runs npm in the project and it writes package-lock.json again
1Check
Search the repo's scripts, CI files and Docker files for npm install or npm ci, and check which commit re-added the file.
grep -rn --include=Dockerfile --include='*.yml' --include='*.yaml' --include='*.sh' -E 'npm (install|ci)' . --exclude-dir=node_modules
git log --oneline --diff-filter=A -- package-lock.json2Fix
Change those steps to use yarn install. Then declare the manager in package.json so the wrong one is refused: Corepack reads the packageManager field and asks you to rerun the command with the right tool. Corepack ships with Node.js 14.19 up to 24; on Node.js 25 and later install it first with npm install -g corepack. npm shims are only created when requested, so name npm in the enable command.
// package.json
"packageManager": "yarn@1.22.22"
# once per machine
corepack enable
corepack enable npm3Verify
Run npm install in the project. Corepack should refuse and tell you to run it with Yarn, and no package-lock.json should appear.
npm install
ls package-lock.jsonConfirmed by raw.githubusercontent.com
Cause 3 of 3
npm-shrinkwrap.json is in the project, which gives a different warning
1Check
Shrinkwrap is npm's publishable lock file. Yarn does not read it and says so, with its own message instead of the package-lock.json one.
ls -l npm-shrinkwrap.json2Fix
Yarn does not support npm shrinkwrap files, because they do not hold enough information for its resolution. Delete the file and commit the yarn.lock that Yarn creates.
git rm npm-shrinkwrap.json
yarn install
git add yarn.lock3Verify
Install once more; the shrinkwrap warning should no longer print.
yarn installConfirmed by classic.yarnpkg.com
How do I stop it coming back?
- Decide on one package manager per repository and write it into the README and the packageManager field.
- Use the same tool in CI, Docker builds and local scripts; a single npm ci in a pipeline is enough to bring the second lock file back.
- Review pull requests that add or change a lock file you do not use.
- Pin the Yarn version in the packageManager field, so every machine and CI job runs the same one.
Sources
How was this page made?
I drafted this page with AI assistance from the official documents listed under Sources. Every cause above names the document that confirms it. I have not reproduced this fix on a machine of my own yet, so read it as documented guidance, not a test report. Found a mistake? Tell me.
Which stack is behind this page?
Projects of mine built on the same technologies:
Related fixes
Web apps
npm ci fails because package.json and the lockfile disagree
`npm ci` can only install packages when your package.json and package-lock.json are in sync. Please update your lock file with `npm install` before continuing.
npm ci refuses to install when the lockfile does not match package.json, or when there is no lockfile.
3 causes, each with a fixBack end
Yarn install fails in CI because the lockfile would change
error Your lockfile needs to be updated, but yarn was run with `--frozen-lockfile`.
Yarn refuses to run when package.json asks for something yarn.lock does not record, and you told it not to touch the lockfile.
2 causes, each with a fixBack end
ng serve says it cannot determine the project or target
Cannot determine project for command.
The Angular CLI looked through angular.json for a project that defines the target you asked for (serve, build, test) and found none, or found several and could not pick one.
3 causes, each with a fixBack end
ng fails with Cannot find module @angular/cli/bin/ng
Cannot find module '@angular/cli/bin/ng'
The ng command is the entry point to the Angular CLI package.
2 causes, each with a fixBack end
Angular app shows 'Cannot GET /' when served by a Node.js server
Cannot GET /dashboard
Cannot GET / is Express saying no route or file matches the request.
3 causes, each with a fixBack end
ng serve cannot find the dev-server builder package
Could not find the implementation for builder @angular/build:dev-server
The builder named in angular.json (for example @angular-devkit/build-angular:dev-server) is looked up as an npm package starting from the workspace root.
3 causes, each with a fix