Uncaught Error: Module did not self-register
Javascriptnode.jsNode WebkitNode FfiJavascript Problem Overview
I try to use node-vlc with nw.js (v0.12.0-alpha2). When i launch my app without nw.js it works, but when i launch it with nw.js i got an error:
> Uncaught Error: Module did not self-register.", source: /home/alexis/Bureau/dev/jukebox/node_modules/vlc/node_modules/ffi/node_modules/bindings/bindings.js (84)
I tried some commands with nw-gyp but it couldn't help me. I am on Ubuntu 14, 64-bit.
Javascript Solutions
Solution 1 - Javascript
If you've upgraded node then npm rebuild
might fix this for you
Solution 2 - Javascript
For me:
rm -r node_modules
then
npm install
Solution 3 - Javascript
I had a similar issue with another product and my fix was to change the version of node I was using. I was using 0.12.0
and changed back to 0.10.26
.
Personally, I use NVM to handle node version changing. With NVM installed it's as simple as running
nvm use 0.10.26
Or setting the default version to 0.10.26
nvm alias default 0.10.26
Hopefully this helps you out - our issues came from different products but the solution may be the same.
Solution 4 - Javascript
I had similar problem.
> /Users/user/NodeAddons/bridge/node_modules/bindings/bindings.js:83 > Error: Module did not self-register.
In my case I was doing a C/C++ Add-on, and I had forgotten to export the add-on, in my main.cc was missing the code below:
void Init(v8::Handle<v8::Object> exports) {
NODE_SET_METHOD(exports, "method", method);
}
NODE_MODULE(method, Init);
Hope this helps others! Thanks :)
Solution 5 - Javascript
I've add the same issue because I installed to modules as sudo... Removing the node modules folder and reinstalling as normal user fixed it.
Solution 6 - Javascript
For me npm rebuild
or npm update
didn't work. I had to remove the node_modules
folder and run npm install
to install them again.
Solution 7 - Javascript
I once had this problem when creating a multi-file c++ addon. In my binding.gyp file I had:
"sources": ["src/*.cc", "src/*.h" ]
And my project contained several *.cc files. However, the NODE_MODULE() macro was called only on one file which imported the rest of the files. But node expects that it is called on the frist *.cc file listed in sources. So I had to change sources to explicitly add that file to the beginning
Solution 8 - Javascript
For me, running npm update
worked
Solution 9 - Javascript
I was getting an internal error: Module did not self-register
.
- Deleted the node_modules folder
- ran
npm install
It worked just fine.
Solution 10 - Javascript
I had this error with Snappy. Was using Node 11. Checked Snappy's NPM page https://www.npmjs.com/package/snappy where they listed which versions of node they supported.
Deleting node_modules folder rm -rf node_modules
and then reinstalling using the correct version of Node resolved it.
One of the versions they supported on Linux at the time of this writing was Node version 12.
nvm deactivate 11
nvm uninstall 11
nvm install 12
nvm use 12
Problem solved
Another cause of this problem: if you're using pm2, then after upgrading node you may need to reinstall pm2. Test whether pm2 is the issue by running your app
without pm2 node server.js
then with pm2: pm2 start server.js
.
https://stackoverflow.com/questions/26205065/proper-way-to-update-pm2-after-updating-node-js
Solution 11 - Javascript
I had this same issue with 0.12 and io.js 1.3.0, reverting to Node.js 0.10 fixed the issue.
Solution 12 - Javascript
I had the same problem. My script that was referencing a global reference script had an invalid reference. I took off that invalid reference and the error was gone. My error message had no indication of that particular invalid reference which made it harder to debug. But 'Uncaught Error: Module did not self-register' was the message I was getting.
This also happen in my other project. For some reason, it wouldn't recognize the reference path if one of the characters are uppercase. Even thought, the upper-casing was the correct spelling of the path.
Solution 13 - Javascript
I had this issue while setting up my Cypress project.
I found out the issue was caused because Cypress uses node from its bundle version by default (which was version 8.0 in my case) , whilst the package I wanted to use required the node version to be 10 or higher.
I did have node 12.0 installed on my machine but since cypress was not using that I had to add the line shown below in the settings file (cypress.json) to set the value for 'nodeVersion' to 'system', to tell cypress explicitly to use the node version installed on my machine.
Add this line to your settings file:
**"nodeVersion": "system"**