我正在使用Electron模块mdns,我收到此错误
A JavaScript error occurred in the main process
Uncaught Exception:
Error: Module version mismatch. Expected 49, got 48.
at Error (native)
at process.module.(anonymous function) [as dlopen] (ELECTRON_ASAR.js:167:20)
at Object.Module._extensions..node (module.js:568:18)
at Object.module.(anonymous function) [as .node] (ELECTRON_ASAR.js:167:20)
at Module.load (module.js:458:32)
at tryModuleLoad (module.js:417:12)
at Function.Module._load (module.js:409:3)
at Module.require (module.js:468:17)
at require (internal/module.js:20:19)
at Object.<anonymous> (/home/ingsaurabh/dp/node_modules/mdns/lib/dns_sd.js:24:20)
卸载节点模块并重新安装,但无法正常工作
答案 0 :(得分:2)
npm rebuild --runtime = electron --target = 1.3.4 --disturl = https://atom.io/download/atom-shell --abi = 50
在你的情况下它应该 49
答案 1 :(得分:1)
由于mdns
包含本机节点模块,您必须重建它以定位您的Electron版本,有a couple of ways to do this。我建议使用electron-rebuild
方法。
答案 2 :(得分:1)
升级节点版本时,这是众所周知的问题。例如:您正在使用Node作为示例版本5.您在项目中添加了一些库,构建并运行它。您的所有库都将在节点版本5下编译。
然后将节点升级到版本6.然后运行一些使用node的命令,例如npm run test。问题在于:您使用较新的节点版本来运行由旧节点编译的库。
通过以下两个命令解决这个问题很简单:
rm -rf node_modules // force remove node_modules directory
npm install // install again all libraries. Libraries will be compiled again with node version 6
所以这是一个适用于所有javascript框架的通用方法,不仅适用于electron
...