Javascript 未捕获的错误:模块没有自注册
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/28486891/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
Uncaught Error: Module did not self-register
提问by Alexis Schad
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:
我尝试将 node-vlc 与 nw.js (v0.12.0-alpha2) 一起使用。当我在没有 nw.js 的情况下启动我的应用程序时,它可以工作,但是当我用 nw.js 启动它时,出现错误:
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)
未捕获的错误:模块未自行注册。”,来源:/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.
我用 nw-gyp 尝试了一些命令,但它无法帮助我。我使用的是 64 位 Ubuntu 14。
回答by DiverseAndRemote.com
If you've upgraded node then npm rebuildmight fix this for you
如果您已升级节点,则npm rebuild可能会为您解决此问题
回答by Thami Bouchnafa
For me:
rm -r node_modulesthen
npm install
对我来说:
rm -r node_modules然后
npm install
回答by joel.bowen
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.0and changed back to 0.10.26.
我在另一个产品上遇到了类似的问题,我的解决方法是更改我正在使用的节点版本。我正在使用0.12.0并改回0.10.26.
Personally, I use NVMto handle node version changing. With NVM installed it's as simple as running
就个人而言,我使用NVM来处理节点版本更改。安装 NVM 就像运行一样简单
nvm use 0.10.26
Or setting the default version to 0.10.26
或者将默认版本设置为 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.
希望这对您有所帮助 - 我们的问题来自不同的产品,但解决方案可能相同。
回答by Aion
I had similar problem.
我有类似的问题。
/Users/user/NodeAddons/bridge/node_modules/bindings/bindings.js:83 Error: Module did not self-register.
/Users/user/NodeAddons/bridge/node_modules/bindings/bindings.js:83 错误:模块未自行注册。
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:
就我而言,我正在做一个 C/C++ 附加组件,但我忘记导出附加组件,在我的 main.cc 中缺少以下代码:
void Init(v8::Handle<v8::Object> exports) {
NODE_SET_METHOD(exports, "method", method);
}
NODE_MODULE(method, Init);
Hope this helps others! Thanks :)
希望这对其他人有帮助!谢谢 :)
回答by user1485083
I once had this problem when creating a multi-file c++ addon. In my binding.gyp file I had:
我在创建多文件 c++ 插件时曾经遇到过这个问题。在我的 binding.gyp 文件中,我有:
"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
我的项目包含几个 *.cc 文件。但是,NODE_MODULE() 宏仅在一个文件上调用,该文件导入了其余文件。但是 node 期望在源代码中列出的第一个*.cc 文件上调用它。所以我不得不更改来源以明确地将该文件添加到开头
回答by inolasco
For me, running npm updateworked
对我来说,跑步很npm update有效
回答by silveur
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.
我添加了同样的问题,因为我以 sudo 的身份安装到模块中......删除节点模块文件夹并以普通用户身份重新安装修复了它。
回答by Jesús Carrera
For me npm rebuildor npm updatedidn't work. I had to remove the node_modulesfolder and run npm installto install them again.
对我来说npm rebuild还是npm update没用。我不得不删除该node_modules文件夹并运行npm install以再次安装它们。
回答by Matthew O'Riordan
I had this same issue with 0.12 and io.js 1.3.0, reverting to Node.js 0.10 fixed the issue.
我在 0.12 和 io.js 1.3.0 上遇到了同样的问题,恢复到 Node.js 0.10 解决了这个问题。
回答by Good4Nothing
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.
这也发生在我的另一个项目中。出于某种原因,如果其中一个字符是大写的,它将无法识别参考路径。甚至认为,大写是路径的正确拼写。

