为什么在Electron和Node.JS之间模块版本不匹配? [英] Why is there a mismatch of module versions between Electron and Node.JS?

查看:72
本文介绍了为什么在Electron和Node.JS之间模块版本不匹配?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个节点项目,其中使用NodeJS 14.15.0 和最新版本的Electron 12.0.0 .

NodeJS版本 14.15.0

电子版本 v12.0.0 使用此节点版本的 14.15.0 .但在他们的

因此,我在这两个版本之间不匹配.我需要一个匹配项,以便可以加载相同的二进制电子版应用程序+由node.js实例执行.

解决方案

电子维护和编译自己的Node分支,其方式可能与普通Node不兼容.电子有意使用唯一的 NODE_MODULE_VERSION 将这一事实告知软件.

您需要使用 electron-rebuild 重新编译本机模块.

Electron支持本机节点模块,但是由于Electron很可能使用与系统上安装的Node二进制文件不同的V8版本,因此需要重新编译您使用的模块以用于Electron.

(电子文档)

Node和Electron的维护者讨论了可能的选项,并决定在此问题中使用偏移版本控制:

https://github.com/nodejs/TSC/issues/651

I have a node project in which I use NodeJS 14.15.0 and the latest build of Electron 12.0.0.

NodeJS version 14.15.0 has a NODE_MODULE_VERSION 83 according to their webpage.

Electron version v12.0.0 uses this node version of 14.15.0. but on their webpage it says the module NODE_MODULE_VERSION is 87

Therefore I have a mismatch between these two versions. I need a match so I can load the same binary intro an Electron app + execute by a node.js instance.

解决方案

Electron maintains and compiles their own fork of Node, in a way that may not be compatible with normal Node. Electron intentionally uses unique NODE_MODULE_VERSION to signal this fact to software.

You'll need to recompile native modules using electron-rebuild.

Native Node modules are supported by Electron, but since Electron is very likely to use a different V8 version from the Node binary installed on your system, the modules you use will need to be recompiled for Electron.

(electron docs)

The maintainers of Node and Electron discussed possible options, and decided to use offset versioning in this issue:

https://github.com/nodejs/TSC/issues/651

这篇关于为什么在Electron和Node.JS之间模块版本不匹配?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆