How to fix npm ERR! Error: ENOENT: no such file or directory, open 'npm-shrinkwrap.json' in npm

npmBEGINNERMEDIUMUpdated Dec 2, 2025· 121 views

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
  1. Confirm the file and working directory
  2. Restore or generate the shrinkwrap
  3. Or switch to package-lock.json
  4. Clean and reinstall
npm — error
pwd
ls npm-shrinkwrap.json
npm 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

  1. npm-shrinkwrap.json deleted, renamed, or .gitignored
  2. Running npm in the wrong package directory
  3. CI script forcing npm-shrinkwrap usage while the project uses package-lock
  4. Incomplete checkout (sparse/partial) missing the file
  5. 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'"

1Confirm the file and working directory
bash
pwd
ls npm-shrinkwrap.json

If missing, ensure you are in the package root that owns the shrinkwrap.

2Restore or generate the shrinkwrap
bash
git checkout -- npm-shrinkwrap.json || true
npm shrinkwrap

Commit the file if your pipeline expects it.

3Or switch to package-lock.json

If your project uses package-lock.json, update CI scripts to stop requiring shrinkwrap and ensure package-lock is committed.

4Clean and reinstall
bash
rm -rf node_modules package-lock.json npm-shrinkwrap.json
npm install --package-lock-only
npm ci
5Handle monorepos

Run 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