Uncaught Error: Module did not self-register

2019-01-10 18:31发布

问题:

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.

回答1:

If you've upgraded node then npm rebuild might fix this for you



回答2:

For me: rm -r node_modules then npm install



回答3:

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.



回答4:

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 :)



回答5:

For me, running npm update worked



回答6:

I had this same issue with 0.12 and io.js 1.3.0, reverting to Node.js 0.10 fixed the issue.



回答7:

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.



回答8:

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.



回答9:

i was also facing the same issue and this one worked for me.

you need to go in the node_module/ and configure the nw-gyp target by following command

$ nw-gyp configure --target=0.12.3 

then

$ nw-gyp build

and this worked for me. If you get nw-gyp command not found then use

npm install nw-gyp


回答10:

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



回答11:

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.



回答12:

Mac:

For me, below actions work: node v0.12.2

npm rebuild
rm -rf node_modules
npm i