Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

npm ERR! cb.apply is not a function

I am getting this error

npm ERR! cb.apply is not a function 

in Linux while doing npm install although my npm version is 6.9.0. My node version is v12.18.3. How to resolve this issue?

like image 332
Janaki Avatar asked Aug 15 '20 18:08

Janaki


People also ask

How do you fix npm err CB apply is not a function?

To resolve this issue, you need to update npm to v6. 10.0 and above. When this happens, then your next option is to download the latest version of Node from nodejs.org. The latest LTS version should be enough to resolve the issue.

What is npm CB?

The cb() function mentioned above is a vanilla callback function. The function was used by the npm install command to mark when an install is completed. The error means that the installation process was interrupted and left unfinished.


2 Answers

Would be helpful if you shared if it's Windows or Linux, but the error seems to occur on Windows. Possible solution:

1. Go to C:\Users(your username)\AppData\Roaming 2. Delete the npm folder (possibly back it up) and if there is one npm cache folder. 3. Run `npm cache clear --force` (--force is now required to clean cache) 

After that, npm install should work fine.

like image 158
Marek Piotrowski Avatar answered Sep 21 '22 11:09

Marek Piotrowski


Mac/Macbook users

Since this question is fairly active and a top google result for this issue (I know the OP is using Linux) and we have every other OS covered in this list. Here is how to fix it on a Mac.

On a Mac you do not have the AppData\Roaming folder, so simply run npm root -g and then navigate to the hidden directory and delete the node_modules there. If using nvm you'll need to rerun nvm use x.x.x (where x.x.x is your version).

like image 35
maxshuty Avatar answered Sep 18 '22 11:09

maxshuty