Search code examples
node.jselectronv8

Trying to understand "Since Electron is very likely to use a different V8 version" explanation


Electron Documentation page Using Native Node Modules includes the following explanation:

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.

As an Electron newbie, I know about the main Node.js process and the renderer processes, but the above explanation still makes no sense to me. An explanation of what the above is saying, and why one needs to worry about V8, would be welcome.


Solution

  • Note that this is talking about "native node modules" which I assume means modules that use some "native code" and use the add-on library interface in order to extend node.js with native code.

    Electron packages a specific built of node.js in it's build tools. Some modules you use (like the ones that are not 100% javascript, that include some native code) may need to be "built" for the specific version of node.js that you're running.

    So, all they're saying is that if you're running node v12.13.1 on your development computer, but the version of electron you're using has v10.x in it, then if you have some modules you're using that have native code in them, you may need to rebuild them for the version of V8 built into your electron environment. This wouldn't be so much because of the variations in the Javascript engine (those aren't usually dealt with by compiling), but because of variations in the add-on library that "native code" modules use.