The 'cb() never called' error indicates npm's internal callback function failed to execute during installation. The fix typically involves clearing the npm cache, checking network connectivity, or updating npm/Node.js versions.
The "npm ERR! cb() never called!" error indicates that npm's internal callback function failed to execute during the installation process, leaving the package installation incomplete. The "cb()" function is a vanilla callback used by npm to mark when an install completes, and when it never gets called, npm has no way to know the installation finished. This error typically points to infrastructure issues (corrupted cache, network problems, or version incompatibilities) rather than problems with your code or dependencies themselves. Something interrupted the process before completion. The error is often related to network connectivity timeouts, corrupted npm cache, or incompatibilities between Node.js and npm versions.
Before making any changes, ensure you can reach the npm registry:
# Test connectivity to npmjs.org
ping registry.npmjs.org
# Or verify HTTPS access with curl
curl -I https://registry.npmjs.org/If you cannot reach the registry, check your internet connection and any firewall/proxy settings. If you're behind a proxy, configure npm:
npm config set proxy http://proxy.example.com:8080
npm config set https-proxy http://proxy.example.com:8080This is the first troubleshooting step recommended by npm maintainers:
# Verify cache integrity and report issues
npm cache verify
# If verify shows corruption, force a clean
npm cache clean --force
# Verify again after cleaning
npm cache verifyThe npm cache verify command checks for corrupted data and fixes minor issues automatically. After cleaning, try your install again:
npm installIf cache cleaning doesn't work, perform a complete clean install:
# Remove node_modules directory
rm -rf node_modules
# Remove the lock file
rm package-lock.json
# Verify cache again
npm cache verify
# Fresh install
npm installThis forces npm to re-download everything and rebuild the dependency tree from scratch.
For CI/CD environments, you can add the --no-package-lock flag to skip lock file generation:
npm install --no-package-lockOutdated Node.js or npm versions can have bugs that trigger the "cb() never called" error. Update to the latest stable versions:
# Update npm globally to latest version
npm install -g npm@latest
# Check versions
node --version
npm --versionIf you're using an older Node.js version (pre-8.0), upgrade to a modern LTS release:
# Install nvm and switch to Node 18
nvm install 18
nvm use 18
npm install # Now try install with newer versionsMultiple users report the issue disappearing after upgrading to Node 18 with npm 8/9.
The error can occur if two packages require incompatible versions of the same dependency:
# Show outdated packages
npm outdated
# List dependency conflicts
npm ls
# Try updating all packages to compatible versions
npm updateReview your package.json file and ensure versions are compatible. If conflicts exist, you may need to:
1. Update packages to newer versions that share compatible dependencies
2. Use npm ci (clean install) instead of npm install
3. Manually adjust version constraints in package.json
If the error persists after all the above steps, some users report that switching to Yarn resolves the issue:
# Install Yarn globally
npm install -g yarn
# Use Yarn to install dependencies instead
yarn install
# Or for CI/CD environments
yarn install --frozen-lockfileYarn uses the same package.json and node_modules folder as npm but has different dependency resolution and caching logic. If npm consistently fails while Yarn succeeds, it indicates a specific incompatibility with your npm version.
Environment-Specific Issues:
- NFS Mounts & Docker: If $HOME and npm's $PREFIX are on different filesystems, npm can encounter cross-device link errors. Configure npm's cache to the same filesystem using npm config set cache /path/on/same/device.
- CI/CD Pipelines: In GitHub Actions, GitLab CI, or Heroku, use npm ci (clean install) instead of npm install to use the exact versions from package-lock.json.
- Corporate Proxies with SSL Inspection: If your organization intercepts SSL traffic, npm may fail SSL validation. As a last resort, disable strict SSL checking: npm config set strict-ssl false (not recommended for security-sensitive projects).
- Memory Constraints: On systems with limited RAM (containers, embedded systems), npm's cache operations can fail. Reduce cache pressure with npm config set cache-min 0.
Reporting: This is documented as a known npm issue. If none of these steps resolve your problem, report it to the npm feedback repository with your Node/npm versions and detailed error logs (npm install --verbose).
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