electron / fiddle

:electron: 🚀 The easiest way to get started with Electron
https://electronjs.org/fiddle
MIT License
7.45k stars 691 forks source link

Native modules are compiled against the wrong headers #200

Open nornagon opened 5 years ago

nornagon commented 5 years ago

Example: https://gist.github.com/9f283e1b807667af397d46639dfb7c45

Error: The module '/private/var/folders/7w/g8kll6857_740r2sgt4prqkr0000gp/T/tmp-95900MdRX1JGTHapG/node_modules/robotjs/build/Release/robotjs.node'
was compiled against a different Node.js version using
NODE_MODULE_VERSION 67. This version of Node.js requires
NODE_MODULE_VERSION 73. Please try re-compiling or re-installing
the module (for instance, using `npm rebuild` or `npm install`).
    at process.func [as dlopen] (electron/js2c/asar.js:152:31)
    at Object.Module._extensions..node (internal/modules/cjs/loader.js:855:18)
    at Object.func [as .node] (electron/js2c/asar.js:152:31)
    at Module.load (internal/modules/cjs/loader.js:682:32)
    at tryModuleLoad (internal/modules/cjs/loader.js:614:12)
    at Function.Module._load (internal/modules/cjs/loader.js:606:3)
    at Module.require (internal/modules/cjs/loader.js:720:19)
    at require (internal/modules/cjs/helpers.js:14:16)
    at Object.<anonymous> (/private/var/folders/7w/g8kll6857_740r2sgt4prqkr0000gp/T/tmp-95900MdRX1JGTHapG/node_modules/robotjs/index.js:1:15)
    at Module._compile (internal/modules/cjs/loader.js:813:30)
nornagon commented 5 years ago

NB. I think the best way to handle this would be to download the node headers along with Electron, e.g. from https://electronjs.org/headers/v4.2.0/node-v4.2.0-headers.tar.gz, and then run npm install with npm_config_nodedir=.../path/to/extracted/headers

MarshallOfSound commented 5 years ago

@nornagon The issue is fiddle npm install's on every launch. Which makes building native modules quite tedious.

I originally wrote this feature into electron-rebuild to solve this issue --> https://github.com/electron/electron-rebuild/pull/242

The idea being fiddle could just run electron-rebuild on the temp dir and it would Handle All The Things

nornagon commented 5 years ago

i'd rather a slow rebuild than a straight-up failure 🤷‍♂