Uncaught Error: Module did not self-register

感情迁移 提交于 2019-11-27 11:44:39

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

Thami Bouchnafa

For me: rm -r node_modules then npm install

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.

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

For me, running npm update worked

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

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.

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.

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

mayank

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

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.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!