npm ERR! cb.apply is not a function— Fixed [Complete Guide 2026]
⚡ Quickest Fix — works 85% of the time
Your npm version is out of sync with your Node.js version. Update npm first:
npm install -g npm@latestThen retry your command. If that did not fix it, read on — every other cause is covered below.
What Causes "npm ERR! cb.apply is not a function"?
Here is the full error:
npm ERR! cb.apply is not a function
npm ERR! A complete log of this run can be found in:
npm ERR! /Users/you/.npm/_logs/2026-01-01T00_00_00_000Z-debug.logUnlike most npm errors, this one does not point to your code or your project at all. cb.apply is not a function is a JavaScript runtime error thrown inside npm's own source code when it tries to call a callback (cb) using .apply() — but cb is undefined instead of a function.
This happens because npm internally relies on Node.js APIs. When your Node.js version and your npm version are out of sync — for example you upgraded Node but not npm, or vice versa — npm calls an internal API that has changed between versions, and the callback it expected is no longer there. The result is this cryptic error.
The good news: the fix is always about aligning your Node and npm versions. Your application code is not the problem.
The Most Common Triggers
- Upgraded Node.js via Homebrew, apt, or the official installer without updating npm
- Installed a new global npm version that is incompatible with your current Node.js
- Switched Node versions with nvm but the active npm is from a different version
- Installed Node.js on a new machine using a very old installer
- Running Node 6, 7, or 8 (end-of-life) with a modern npm — they are incompatible
- Partial or corrupted Node.js installation from a failed upgrade
Run 'node --version' and 'npm --version' right now. Then scroll to the compatibility table below. If your versions do not match the compatible pairs — that is your problem, and Fix 1 or Fix 2 will solve it.
Update npm to Match Your Node Version
Most common fixThe fastest fix in most cases. This updates npm to the latest version that is compatible with your current Node.js installation:
npm install -g npm@latestVerify the update worked:
npm --version # should print a recent version like 10.x.x
node --version # should print your Node versionThen retry whatever command was failing:
npm installOn macOS, if npm is managed by Homebrew, 'npm install -g npm@latest' may not persist after a 'brew upgrade node' because Homebrew overwrites the bundled npm. Use nvm instead (Fix 2) to permanently solve this.
Switch to the Correct Node Version with nvm
Permanent fix — recommendedThe cleanest, most permanent solution is using nvm (Node Version Manager) to install a matched Node + npm pair. nvm installs each Node version with its own bundled npm, keeping them in sync automatically.
Install nvm — macOS / Linux
curl -o- https://raw.githubusercontent.com/nvm-sh/nvm/v0.40.0/install.sh | bash
# Reload your shell config
source ~/.zshrc # zsh (default on macOS)
source ~/.bashrc # bashInstall nvm — Windows
Download and run the installer from github.com/coreybutler/nvm-windows. It provides the same interface as nvm on Unix.
Install and use a stable LTS Node version
# Install the latest LTS version (recommended)
nvm install --lts
# Use it
nvm use --lts
# Make it the default for all new terminals
nvm alias default node
# Verify both versions are now in sync
node --version
npm --versionOr install a specific version
nvm install 20 # Node 20 LTS
nvm use 20
nvm alias default 20After switching Node versions with nvm, always run 'npm install' again in your project — node_modules built against a different Node version can cause subtle errors.
Reinstall Node.js Cleanly
When npm update alone doesn't workIf updating npm did not fix it, the Node.js installation itself may be corrupted or partially upgraded. A clean reinstall resolves this.
macOS — via official installer
- Download the latest LTS from nodejs.org
- Run the .pkg installer — it will overwrite the existing installation
- Open a new terminal window (important — old terminal caches the old path)
- Verify: node --version && npm --version
macOS — via Homebrew
brew uninstall node
brew install node
# Verify
node --version
npm --versionUbuntu / Debian Linux
# Remove existing Node
sudo apt remove nodejs npm
sudo apt autoremove
# Install via NodeSource (recommended — gets latest LTS)
curl -fsSL https://deb.nodesource.com/setup_lts.x | sudo -E bash -
sudo apt install -y nodejs
# Verify
node --version
npm --versionWindows
- Open Add or Remove Programs → uninstall Node.js
- Delete any leftover folders: C:\Program Files\nodejs and C:\Users\you\AppData\Roaming\npm
- Download the latest LTS installer from nodejs.org
- Run the installer with default options
- Open a new Command Prompt or PowerShell window
- Verify: node --version && npm --version
Clear npm Cache + Delete node_modules
After fixing Node/npm versionsAfter fixing your Node and npm versions, the npm cache and your existing node_modules were built against the old mismatched versions. Clear both for a completely fresh state:
macOS / Linux
npm cache clean --force
rm -rf node_modules package-lock.json
npm installWindows — PowerShell
npm cache clean --force
Remove-Item -Recurse -Force node_modules
Remove-Item package-lock.json
npm installThis step is important even if npm install seems to work after fixing the version. node_modules built against Node 16 can contain native bindings that are incompatible with Node 20 and cause runtime errors that are hard to trace.
Fix Broken npm on Windows
Windows-specificWindows has a specific additional problem: npm global installs go to %APPDATA%\npm but the Node.js installer puts its bundled npm somewhere else. When these two npm installations get out of sync, cb.apply errors are common.
Find which npm is running
# See the full path of the npm being used
where npm
# or
Get-Command npm | Select-Object -ExpandProperty SourceRemove conflicting global npm
# Remove AppData npm folder contents
Remove-Item -Recurse -Force "$env:APPDATA\npm"
# Reinstall npm cleanly
npm install -g npm@latestEnsure PATH is correct
Open System Properties → Environment Variables → Path and check that C:\Program Files\nodejs appears before any other Node paths. Multiple Node installations on the PATH is a frequent cause of this error on Windows.
If you have both a standalone Node.js installation AND Node installed via another tool like Chocolatey or winget, they can conflict. Pick one installation method and uninstall the other completely.
Nuclear Option — Full Node + npm Reset
When nothing else worksIf every fix above has failed, perform a full reset: remove Node and npm entirely, wipe all caches and global package directories, and reinstall from scratch using nvm.
macOS / Linux
# 1. Uninstall current Node (Homebrew example)
brew uninstall --force node
# 2. Remove npm cache and global packages
rm -rf ~/.npm
rm -rf ~/.nvm # only if reinstalling nvm too
# 3. Install nvm fresh
curl -o- https://raw.githubusercontent.com/nvm-sh/nvm/v0.40.0/install.sh | bash
source ~/.zshrc
# 4. Install Node LTS via nvm
nvm install --lts
nvm use --lts
nvm alias default node
# 5. Verify
node --version
npm --version
# 6. Reinstall your project dependencies
cd your-project
rm -rf node_modules package-lock.json
npm installWindows
- Uninstall Node.js from Add or Remove Programs
- Delete C:\Program Files\nodejs
- Delete C:\Users\you\AppData\Roaming\npm and npm-cache
- Delete C:\Users\you\AppData\Local\nvm (if using nvm-windows)
- Restart Windows
- Download and install nvm-windows from github.com/coreybutler/nvm-windows
- Run: nvm install lts && nvm use lts
- Verify: node --version && npm --version
Compatible Node.js and npm Version Pairs
This is the key reference table. If your Node and npm versions are not on the same row, they are likely incompatible — and that is the root cause of your error.
Node.js LTS Releases and Bundled npm Versions
| Node.js version | Bundled npm | LTS status | Recommended? |
|---|---|---|---|
| Node 22.x | npm 10.x | Active LTS | ✅ Yes |
| Node 20.x | npm 10.x | Active LTS | ✅ Yes |
| Node 18.x | npm 9.x | Maintenance LTS | ✅ Yes |
| Node 16.x | npm 8.x | End of Life | ⚠️ Upgrade now |
| Node 14.x | npm 6.x | End of Life | ❌ No |
| Node 12.x | npm 6.x | End of Life | ❌ No |
| Node 10.x | npm 6.x | End of Life | ❌ No |
You can safely run a newer npm than the bundled version on any Node release — for example npm 10 on Node 18 works fine. What breaks things is running a much older npm on a newer Node, or running end-of-life Node versions with any modern npm.
OS-Specific Notes
macOS
The most common macOS trigger: running brew upgrade which upgrades Node.js but leaves the system npm untouched. After any Homebrew Node upgrade, always run npm install -g npm@latest immediately. Better long-term: switch to nvm entirely and uninstall the Homebrew Node — Homebrew and nvm managing Node simultaneously causes conflicts.
Windows
Windows users most commonly hit this after using the Node.js official installer. The installer bundles a specific npm version — if you later run npm install -g npm@latest, it installs a newer npm into %APPDATA%\npm while the old bundled npm still sits in C:\Program Files\nodejs. Depending on which one is first in your PATH, you can end up running a mismatched combination. The permanent fix is using nvm-windows.
Linux
On Ubuntu and Debian, installing Node via apt often installs an outdated version from the distro's package repository — sometimes as old as Node 12. Always use the NodeSource repository or nvm to get a current Node version on Linux. The system apt package for nodejs is almost always too old for modern npm.
node --version
# If this prints v12.x or v14.x, upgrade immediately via NodeSource or nvmHow to Prevent This Error Permanently
- Use nvm to manage Node.js — it installs matching npm versions automatically and makes switching trivial
- After any Node.js upgrade, immediately run: npm install -g npm@latest
- Never run end-of-life Node versions (anything below 18.x as of 2026)
- On macOS: do not mix Homebrew Node and nvm Node — pick one and stick to it
- On Windows: use nvm-windows instead of the official Node.js installer
- Add a .nvmrc file to your project root to pin the Node version for your whole team
- In CI/CD pipelines, always specify an exact Node version using actions/setup-node or similar
Pin your project's Node version with .nvmrc
20nvm use # automatically reads .nvmrc and switches to Node 20
npm installQuick Reference — Fix Order
- 1npm install -g npm@latest → retry85%
- 2nvm install --lts && nvm use --lts → retry95%
- 3Reinstall Node.js cleanly → retry97%
- 4Clear cache + delete node_modules → npm install98%
- 5Fix conflicting npm paths on Windows99%
- 6Full Node + npm nuclear reset via nvm99.9%
Frequently Asked Questions
What does "npm ERR! cb.apply is not a function" mean?+−
Why does upgrading Node.js cause this error?+−
How do I check my Node and npm versions?+−
Will updating npm fix cb.apply is not a function?+−
Does this error happen on all operating systems?+−
Can I get this error with nvm-installed Node?+−
What is the safest way to manage Node and npm to avoid version conflicts?+−
Need Expert Help?
We Build Production-Grade Next.js & Node.js Apps
Softplix is a full-stack development agency. Dealing with complex Node.js environment issues on a production project? We can fix your setup and keep it clean.
Talk to an Engineer