uhop / node-re2

node.js bindings for RE2: fast, safe alternative to backtracking regular expression engines.
Other
495 stars 53 forks source link

Node module version error #79

Closed Dotnaught closed 4 years ago

Dotnaught commented 4 years ago

Node 12.16.3 NVM 0.35.3 macOS 10.15.6 Electron 10.1.1 re2 1.15.4 npm 6.14.4

I get this error in the console with an RSS app I'm working on. I've tried deleting node_modules and package-lock.json then npm i and ./node_modules/.bin/electron-rebuild but that disconnects Chrome DevTools so I can't inspect the app.

Without the rebuild, the app runs but throws the error below in the console.

Node.js 12.16.3 corresponds with Node Module Version 72.

82 lists Electron 10.

Any ideas beyond reverting to an older version of Electron?

Uncaught Error: The module '/Users/xxx/Code/Git/xxx/node_modules/re2/build/Release/re2.node' was compiled against a different Node.js version using NODE_MODULE_VERSION 72. This version of Node.js requires NODE_MODULE_VERSION 82. 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:140) at Object.Module._extensions..node (internal/modules/cjs/loader.js:1196) at Object.func [as .node] (electron/js2c/asar.js:140) at Module.load (internal/modules/cjs/loader.js:981) at Module._load (internal/modules/cjs/loader.js:881) at Function.Module._load (electron/js2c/asar.js:769) at Module.require (internal/modules/cjs/loader.js:1023) at require (internal/modules/cjs/helpers.js:77) at Object. (/Users/xxx/Code/Git/xxx/node_modules/re2/re2.js:3) at Object. (/Users/xxx/Code/Git/xxx/node_modules/re2/re2.js:26)

uhop commented 4 years ago

It looks like there are two different environments with different Node versions. One environment is used to build a library, another is to run it. There is no way around it.

Electron comes with some black magic for native modules, which breaks when precompiled modules are used — looks like it uses a wrong Node for it. There is even a note about it.

re2 does not use node-gyp-pre but relies on similar technology. There is a way to bypass getting a precompiled module: just define an environment variable DEVELOPMENT_SKIP_GETTING_ASSET (any non-empty value would do) and it will revert to always build it from source code as recommended by Electron.

Let me know if it works for you and I'll add it to the wiki.

Dotnaught commented 4 years ago

Thanks. That got rid of the error.

My code still produces the issue where the main Electron window doesn't appear to load -- the same result when I did npm rebuild. But at least it executes and outputs to the console, which it failed to do before. I suspect it's working properly under the hood and there's an issue with my content security policy that its preventing the window from displaying properly. I'll deal with that when I have time.

Thanks again.

uhop commented 4 years ago

Added to the wiki: https://github.com/uhop/node-re2/wiki/Problem:-ABI-mismatch-in-Electron