【问题标题】:Module version mismatch. Expected 49, got 48模块版本不匹配。预期 49,得到 48
【发布时间】:2016-11-28 01:57:51
【问题描述】:

我正在使用 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)

卸载节点模块并重新安装,但无法正常工作

【问题讨论】:

    标签: node.js electron


    【解决方案1】:

    npm rebuild --runtime=electron --target=1.3.4 --disturl=https://atom.io/download/atom-shell --abi=50

    在你的情况下应该是 49

    【讨论】:

      【解决方案2】:

      由于mdns 包含一个本机 Node 模块,您必须重新构建它以针对您的 Electron 版本,所以有 a couple of ways to do this。我建议使用electron-rebuild 方法。

      【讨论】:

        【解决方案3】:

        这是升级节点版本时众所周知的问题。例如:您使用的是 Node,例如版本 5。您在项目中添加了一些库,构建并运行它。您的所有库都将在节点版本 5 下编译。

        然后你将你的节点升级到版本 6。然后你运行一些使用节点的命令,例如 npm run test。问题出在这里:您使用较新的节点版本来运行由较旧节点编译的库。

        通过以下 2 个命令很容易解决这个问题:

        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 ...

        【讨论】:

          猜你喜欢
          • 2016-12-09
          • 1970-01-01
          • 1970-01-01
          • 1970-01-01
          • 2019-03-02
          • 1970-01-01
          • 1970-01-01
          • 2020-06-06
          • 2018-06-26
          相关资源
          最近更新 更多