The EBADSHRINKWRAP error occurs when npm detects structural or data inconsistencies in the npm-shrinkwrap.json file, typically from corruption, platform-specific dependencies, or conflicting versions.
The EBADSHRINKWRAP error occurs when npm detects structural or data inconsistencies in the npm-shrinkwrap.json file (or package-lock.json). This typically happens when the lock file doesn't match the actual packages installed in node_modules, or when the lock file itself becomes corrupted. The shrinkwrap file serves as a precise record of which package versions should be installed, so when npm detects discrepancies, it halts the installation process to prevent unpredictable behavior. This is a safety mechanism, though the error message doesn't always clearly indicate the root cause. This issue is common when working across different operating systems (macOS to Linux), different npm versions, or after interrupted installations.
Remove the corrupted lock file and node_modules, then reinstall:
# Remove node_modules and all lock files
rm -rf node_modules npm-shrinkwrap.json package-lock.json
# Perform a clean install
npm install
# Regenerate the shrinkwrap file
npm shrinkwrapThis forces npm to fetch fresh dependency metadata from the registry and creates a clean lock file.
If you still have node_modules but the lock file is stale:
# Remove extraneous packages
npm prune
# Regenerate the shrinkwrap file
npm shrinkwrapnpm prune removes packages from node_modules that aren't listed in package.json, eliminating "extraneous" packages that cause EBADSHRINKWRAP errors.
Cached package metadata can sometimes be stale or corrupt:
# Clear the npm cache completely
npm cache clean --force
# Remove lock files and node_modules
rm -rf node_modules npm-shrinkwrap.json package-lock.json
# Reinstall everything
npm installEnsure package.json and lock file match:
# Ensure package.json and lock file match
npm install
# Check that installation succeeded completely
npm ls
# If no errors, regenerate the lock file
rm npm-shrinkwrap.json
npm shrinkwrapRun npm ls to see the full dependency tree and identify any issues.
If your team works across different operating systems, avoid npm-shrinkwrap.json:
# Remove npm-shrinkwrap.json (it takes precedence)
rm npm-shrinkwrap.json
# Let npm generate package-lock.json on install
npm install
# Commit package-lock.json instead
git add package-lock.json
git commit -m "Use package-lock.json for cross-platform compatibility"package-lock.json handles cross-platform dependencies better than shrinkwrap.
Version mismatches can cause lockfileVersion incompatibilities:
# Add a .nvmrc file to specify Node.js version
echo "18.0.0" > .nvmrc
# Team members update to match
nvm install $(cat .nvmrc)
npm install --global npm@9Create a .nvmrc file specifying your Node.js version and document the required npm version in your README.
Why npm-shrinkwrap.json is problematic: The npm-shrinkwrap.json feature has a fundamental design issue—it's included when publishing packages to npm, meaning shrinkwraps from published packages can lock downstream consumers to incompatible versions. Many organizations avoid using npm-shrinkwrap.json entirely in favor of package-lock.json, which is only used locally.
Idempotency issues: npm's original implementation of shrinkwrap had a critical flaw: running npm shrinkwrap multiple times without modifying package.json could produce different results. Modern npm versions have improved this, but it's still a reason to avoid regenerating shrinkwrap files unnecessarily.
Legacy peer dependencies: If you have legacy-peer-deps=true configured globally or in .npmrc, this can cause npm to silently accept incompatible peer dependencies and modify the lock file in ways that break CI builds.
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