npmNode.jsError Fix2026 Updated

npm ERR! cb.apply is not a function— Fixed [Complete Guide 2026]

January 20266 min readnpm · Node.js · All OS

⚡ 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@latest

Then 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:

Terminal 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.log

Unlike 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

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.

1

Update npm to Match Your Node Version

Most common fix
1 minute

The fastest fix in most cases. This updates npm to the latest version that is compatible with your current Node.js installation:

terminal
npm install -g npm@latest

Verify the update worked:

terminal
npm --version   # should print a recent version like 10.x.x
node --version  # should print your Node version

Then retry whatever command was failing:

terminal
npm install

On 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.

2

Switch to the Correct Node Version with nvm

Permanent fix — recommended
3–5 minutes

The 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

terminal
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   # bash

Install 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

terminal
# 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 --version

Or install a specific version

terminal
nvm install 20      # Node 20 LTS
nvm use 20
nvm alias default 20

After 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.

3

Reinstall Node.js Cleanly

When npm update alone doesn't work
5–10 minutes

If 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

terminal
brew uninstall node
brew install node

# Verify
node --version
npm --version

Ubuntu / Debian Linux

terminal
# 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 --version

Windows

  • 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
4

Clear npm Cache + Delete node_modules

After fixing Node/npm versions
2 minutes

After 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

terminal
npm cache clean --force
rm -rf node_modules package-lock.json
npm install

Windows — PowerShell

powershell
npm cache clean --force
Remove-Item -Recurse -Force node_modules
Remove-Item package-lock.json
npm install

This 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.

5

Fix Broken npm on Windows

Windows-specific
5 minutes

Windows 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

PowerShell
# See the full path of the npm being used
where npm
# or
Get-Command npm | Select-Object -ExpandProperty Source

Remove conflicting global npm

PowerShell (Administrator)
# Remove AppData npm folder contents
Remove-Item -Recurse -Force "$env:APPDATA\npm"

# Reinstall npm cleanly
npm install -g npm@latest

Ensure 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.

6

Nuclear Option — Full Node + npm Reset

When nothing else works
10 minutes

If 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

terminal
# 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 install

Windows

  • 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 versionBundled npmLTS statusRecommended?
Node 22.xnpm 10.xActive LTS✅ Yes
Node 20.xnpm 10.xActive LTS✅ Yes
Node 18.xnpm 9.xMaintenance LTS✅ Yes
Node 16.xnpm 8.xEnd of Life⚠️ Upgrade now
Node 14.xnpm 6.xEnd of Life❌ No
Node 12.xnpm 6.xEnd of Life❌ No
Node 10.xnpm 6.xEnd 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.

Linux — check if your apt Node is outdated
node --version
# If this prints v12.x or v14.x, upgrade immediately via NodeSource or nvm

How to Prevent This Error Permanently

Pin your project's Node version with .nvmrc

.nvmrc (project root)
20
terminal — any developer cloning the repo just runs:
nvm use      # automatically reads .nvmrc and switches to Node 20
npm install

Quick Reference — Fix Order

  1. 1npm install -g npm@latest → retry85%
  2. 2nvm install --lts && nvm use --lts → retry95%
  3. 3Reinstall Node.js cleanly → retry97%
  4. 4Clear cache + delete node_modules → npm install98%
  5. 5Fix conflicting npm paths on Windows99%
  6. 6Full Node + npm nuclear reset via nvm99.9%

Frequently Asked Questions

What does "npm ERR! cb.apply is not a function" mean?+
This error means npm tried to call a function using the .apply() method but the value it was trying to call was not a function — it was undefined or some other non-function type. The root cause is almost always a Node.js and npm version mismatch: you upgraded Node but npm is still an old version that is incompatible with the new Node internals.
Why does upgrading Node.js cause this error?+
npm ships bundled with Node.js, but the bundled npm version and a separately installed npm version can get out of sync. When you upgrade Node via a package manager like Homebrew or the official installer without also upgrading npm, the old npm tries to call internal Node APIs that have changed or been removed in the new Node version — causing cb.apply to fail.
How do I check my Node and npm versions?+
Run 'node --version' and 'npm --version' in your terminal. Then cross-reference with the compatibility table — each major Node version ships with a specific bundled npm version that is guaranteed compatible.
Will updating npm fix cb.apply is not a function?+
Yes, in most cases. Running 'npm install -g npm@latest' updates npm to the latest version which is compatible with current Node.js releases. If you are on a very old Node version, you may need to upgrade Node instead of (or as well as) npm.
Does this error happen on all operating systems?+
Yes — macOS, Windows, and Linux can all produce this error. It is most common on macOS when Node is managed via Homebrew (which can upgrade Node independently of npm) and on Windows after using the Node.js installer which bundles a specific npm version.
Can I get this error with nvm-installed Node?+
It is much less common with nvm because nvm installs a matching npm version alongside each Node version. However it can still occur if you manually upgrade npm globally to a version that is incompatible with the nvm Node version you are using. The fix is to run 'nvm use <version>' to switch to a matching Node version.
What is the safest way to manage Node and npm to avoid version conflicts?+
Use nvm (Node Version Manager) on macOS and Linux, or nvm-windows on Windows. nvm installs each Node version with its own matched npm, keeps them isolated, and lets you switch between versions instantly. It is the most reliable way to avoid Node/npm version mismatch errors permanently.

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