How to fix npm ERR! Error: ENOENT: no such file or directory, open 'npm-shrinkwrap.json' in npm
npm was told to use npm-shrinkwrap.json but the file is missing or not in the current directory. Commit or generate it, or switch to package-lock.json before rerunning.
Quick fix
Fixes npm ERR! Error: ENOENT: no such file or directory, open 'npm-shrinkwrap.json'
pwd
ls npm-shrinkwrap.json- Confirm the file and working directory
- Restore or generate the shrinkwrap
- Or switch to package-lock.json
- Clean and reinstall
pwdls npm-shrinkwrap.jsonnpm ERR! Error: ENOENT: no such file or directory, open 'npm-shrinkwrap.json'
What this error means
npm prefers npm-shrinkwrap.json over package-lock.json when present. Some CI setups or older npm versions expect that file; if it is missing, renamed, or not checked in, fs.open fails with ENOENT and npm stops. This often happens after deleting the shrinkwrap file, migrating to package-lock without updating scripts, or in monorepos where the current directory differs from where the shrinkwrap lives.
Typical symptoms
- npm ci/install fails opening npm-shrinkwrap.json
- Shrinkwrap referenced in CI scripts but not present in repo
- Works locally (package-lock) but fails in CI expecting shrinkwrap
- Monorepo package missing its shrinkwrap while root has one
- Merge conflicts removed npm-shrinkwrap.json
Common causes
- npm-shrinkwrap.json deleted, renamed, or .gitignored
- Running npm in the wrong package directory
- CI script forcing npm-shrinkwrap usage while the project uses package-lock
- Incomplete checkout (sparse/partial) missing the file
- Migration from npm-shrinkwrap to package-lock not reflected in pipeline
How to fix "npm ERR! Error: ENOENT: no such file or directory, open 'npm-shrinkwrap.json'"
pwd
ls npm-shrinkwrap.jsonIf missing, ensure you are in the package root that owns the shrinkwrap.
git checkout -- npm-shrinkwrap.json || true
npm shrinkwrapCommit the file if your pipeline expects it.
If your project uses package-lock.json, update CI scripts to stop requiring shrinkwrap and ensure package-lock is committed.
rm -rf node_modules package-lock.json npm-shrinkwrap.json
npm install --package-lock-only
npm ciRun npm from the package directory that owns the shrinkwrap. Each package can have its own lock; ensure the correct one exists.
Advanced notes
npm resolves to npm-shrinkwrap.json before package-lock.json; keeping both can confuse CI—pick one. If you migrate off shrinkwrap, update npm to v7+ and remove scripts that expect it. In workspaces, each package may manage its own lock; ensure the shrinkwrap is committed for each published package to preserve exact versions.
Frequently asked questions
- What does "npm ERR! Error: ENOENT: no such file or directory, open 'npm-shrinkwra" mean?
- json when present. open fails with ENOENT and npm stops. This often happens after deleting the shrinkwrap file, migrating to package-lock without updating scripts, or in monorepos where the current directory differs from where the shrinkwrap lives.
- How do I fix "npm ERR! Error: ENOENT: no such file or directory, open 'npm-shrinkwra"?
- npm was told to use npm-shrinkwrap.json but the file is missing or not in the current directory. Commit or generate it, or switch to package-lock.json before rerunning.
- What causes "npm ERR! Error: ENOENT: no such file or directory, open 'npm-shrinkwra"?
- npm-shrinkwrap.json deleted, renamed, or .gitignored Running npm in the wrong package directory CI script forcing npm-shrinkwrap usage while the project uses package-lock
- Is the "npm ERR! Error: ENOENT: no such file or directory, open 'npm-shrinkwra" error serious?
- It is a medium-severity error — more of a blocker than a risk. The steps above resolve it.
Official resources & further reading
- 📚npm Official Documentation
- 📖npm Docs: npm-shrinkwrap.json(Official Docs)
- 📖npm Docs: package-lock.json(Official Docs)
- 💬Stack Overflow: Missing npm-shrinkwrap.json(Stack Overflow)