How to fix "npm ERR cb() never called" | Quick Fix


How to fix "npm ERR cb() never called" | Quick Fix

Here we will learn how to fix "npm ERR cb() never called" error in our nodejs application easily. This error is very common in any JavaScript frameworks and libraries like reactjs, vuejs too.

Reasons for the error

This error usually occurs

  1. When we install too many node modules packages in our project and due to which sometime our package-lock.json file gets corrupt.
  2. Or sometimes when updating our nodejs version to the latest one, it corrupts the package.json file.

Fixes for "npm ERR cb() never called" error.

To fix the npm err cd() error, i found this four solutions and it fixes my issue.

Solution 1: Clearing the NPM Cache

If the error occurs in local machine then clearing the cache fix the error.

So, first delete the package-lock.json file and then run the following command

npm cache clean --force

and run npm install again to update the package-lock.json file

Solution 2: Upgrade npm version

If you are running on a npm version which is lower than what is required by the package you will get the error.

To upgrade your node version globally , run:

npm install npm@latest -g

Soultion 3: Delete and Install node_modules folder

Delete package-lock.json file and whole node_modules folder and then reinstall everything by running the command:

npm install

Note: Do not delete the package.json file or npm install wont work.

Solution 4: Install the required node version

Sometimes when deploying our application on some online platform like heroku etc, we might get this error. It's because they need a specific node version to work properly.

To fix we just need to specify the specific version in the package.jsonfile.

"engines": {
  "node": "12.x.x"
}

Once you have update your package.json file with correct version, you can deploy it.

I hope the above two solution works for you too. 😀

Related Topics:

Resolve Npm Cannot Find Module Error In Nodejs