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
- When we install too many node module packages in our project sometimes our package-lock.json file gets corrupted.
- Or sometimes when updating our nodejs version to the latest one, it corrupts the package.json file.
Fixes for the “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 the 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 the 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
Solution 3: Delete and Install the 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.json
file.
"engines": {
"node": "12.x.x"
}
Once you have updated your package.json file with the 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
npm WARN package.json: No repository field – Fix
Fixed Error: npm cannot find module error in NodeJS
npm WARN : No description field in Node – Fix
Fixed Error – npm ERR! missing script: dev
NVM Error – exit status 1: Access is denied – Fixed