In this tutorial, we are going to learn about how to fix the Module did not self-register error in Node.js.
When we run an node project, sometimes we see the following error in our terminal.
Uncaught Error: Module did not self-register.", source:
This error occurs when a
node_modules folder is corrupted in your project. Due to the network interruption or other reasons like some of the modules which are already installed in your machine locally, to fix this follow the below steps.
- Remove the
package-lock.jsonfile, inside your project directory by using the below command.
rm-rf node_modules package-lock.json
or you can remove it manually by right-clicking on it and select the
- Clear the npm cache.
npm clean cache --force
- Re-install the node modules again by running the