The ESHRINKWRAP error indicates that your npm-shrinkwrap.json file and package.json are out of sync, usually because package.json was modified without updating the shrinkwrap file.
The ESHRINKWRAP error indicates that your npm-shrinkwrap.json file and package.json are out of sync with your node_modules directory. This error occurs because npm uses the shrinkwrap file to enforce strict version locking for reproducible installs, similar to package-lock.json. When npm detects that the locked versions in shrinkwrap don't match what's declared in package.json, it refuses to proceed, preventing potentially inconsistent dependency trees from being installed. This is a safety mechanism—npm is preventing you from installing a state where your actual dependencies would be ambiguous. The shrinkwrap file should be an exact record of what's installed, but if package.json has been modified (or packages added/removed) without updating the shrinkwrap, npm can't trust which version should actually be installed.
This is the most straightforward solution. It regenerates everything from scratch based on your package.json:
# Remove both the shrinkwrap and node_modules
rm npm-shrinkwrap.json
rm -rf node_modules
# Reinstall all packages (reads from package.json)
npm install
# Regenerate a fresh shrinkwrap file
npm shrinkwrapThis approach is safe because you're starting from the source of truth (package.json) and creating a new shrinkwrap that matches.
If you want to keep the shrinkwrap file but suspect node_modules is out of date:
# Update node_modules to match package.json
npm install
# Update the shrinkwrap to match what's now installed
npm shrinkwrap --saveThe --save flag updates the existing shrinkwrap instead of creating a new one.
Review git history to see if package.json was modified recently:
# View recent changes to package.json
git log --oneline -p package.json | head -50
# See what changed in your local copy
git diff package.jsonIf you made manual edits, either revert them or update properly with npm:
# Revert to last committed version
git checkout package.json
# OR properly install a package
npm install --save package-name@versionIf you just merged branches and shrinkwrap is conflicted, let npm resolve it:
# First resolve any conflicts in package.json manually
# Then run install with --package-lock-only to merge lock files
npm install --package-lock-onlyIf the merge is complex:
# Accept the package.json you want
git checkout --ours package.json # or --theirs
# Remove shrinkwrap entirely
rm npm-shrinkwrap.json
# Reinstall from scratch
npm install
npm shrinkwrapIf shrinkwrap keeps causing issues, modern projects typically use package-lock.json:
# Delete npm-shrinkwrap.json
rm npm-shrinkwrap.json
# npm will auto-generate package-lock.json on next install
npm installAdd to .gitattributes to prevent bad auto-merges:
/npm-shrinkwrap.json merge=binaryWhen to use npm-shrinkwrap.json vs package-lock.json: npm-shrinkwrap.json is primarily intended for published packages (CLI tools, daemons) that will be installed globally—it's published to npm registry. package-lock.json is for regular projects and libraries; it's not published, giving end users flexibility on transitive dependency versions. If both files exist, npm always prefers npm-shrinkwrap.json.
Shrinkwrap best practices: Only use shrinkwrap for applications being deployed as finished products, not libraries. Run npm shrinkwrap immediately before committing—not during active development. Always commit shrinkwrap changes together with the package.json changes that caused them.
In CI/CD pipelines: Use npm ci instead of npm install—it's stricter and will catch shrinkwrap mismatches earlier.
npm ERR! code ENOAUDIT npm ERR! Audit endpoint not supported
How to fix "npm ERR! code ENOAUDIT - Audit endpoint not supported"
npm ERR! code EBADDEVENGINES npm ERR! devEngines.runtime incompatible with current node version
How to fix "npm ERR! code EBADDEVENGINES - devEngines.runtime incompatible with current node version"
npm ERR! code ETOOMANYARGS npm ERR! Too many arguments
How to fix "npm ERR! code ETOOMANYARGS - Too many arguments"
npm ERR! code EINVALIDTAGNAME npm ERR! Invalid tag name: tag names cannot contain spaces
How to fix "npm ERR! code EINVALIDTAGNAME - tag names cannot contain spaces"
npm ERR! code E400 npm ERR! 400 Bad Request
How to fix "npm ERR! code E400 - 400 Bad Request" error