Node.js / npm: Fixing “npm ERR! cb.apply is not a function” on Windows

Lately I ran into this issue and I want to share the exact way I got out of it:

C:\>npm i npm -g
npm WARN npm npm does not support Node.js v14.17.0
npm WARN  npm  You should probably upgrade to a newer version of node as we
npm WARN  npm  can't make any promises that npm will work with this version.
npm WARN  npm  Supported releases of Node.js are the latest release of 6, 8, 9, 10, 11.
npm WARN  npm  You can find the latest version at https://nodejs.org/
npm ERR! cb.apply is not a function
npm ERR! A complete log of this run can be found in:
npm ERR!      %USERPROFILE% \AppData\Roaming\npm-cache\_logs\2021-05-30T14_58_58_367Z-debug.log

It happened right after I installed a newer version of Node.js. But when I checked npm with npm -v, it returned something like 6.*.* — clearly not aligned with the Node version anymore.

What we tried (didn’t help)

  • Reinstall Node.js
  • Remove %USERPROFILE%\AppData\Roaming\npm-cache
  • Uninstall Node.js (together with npm)
  • Install Node.js again
  • Reinstall graceful-fs with npm i -g graceful-fs --force

What finally worked

Nothing… same issue…

Finally we deleted both folders:

%USERPROFILE%\AppData\Roaming\npm
%USERPROFILE%\AppData\Roaming\npm-cache

Then we ran npm i npm -g again. And — voila! — it worked.

I hope it can help someone…

Comments

Popular posts from this blog

Decimal number issue from server to client. Wow! Didn't expect this @_@

Shrinking node_modules for AWS Lambda (My First “npm shock” and a Practical Fix)