mscdex/cap

NODE_MODULE_VERSION 72. This version of Node.js requires NODE_MODULE_VERSION 73. Please try re-compiling or re-installing

Opened this issue ยท 13 comments

App threw an error during load
Error: The module '\\?\C:\Users\talon\OneDrive\Desktop\focus\node_modules\cap\build\Release\cap.node'
was compiled against a different Node.js version using
NODE_MODULE_VERSION 72. 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 (electron/js2c/asar.js:155:31)
    at process.func [as dlopen] (electron/js2c/asar.js:155:31)
    at Object.Module._extensions..node (internal/modules/cjs/loader.js:828:18)
    at Object.func (electron/js2c/asar.js:155:31)
    at Object.func [as .node] (electron/js2c/asar.js:155:31)
    at Module.load (internal/modules/cjs/loader.js:645:32)
    at Function.Module._load (internal/modules/cjs/loader.js:560:12)
    at Module.require (internal/modules/cjs/loader.js:685:19)
    at require (internal/modules/cjs/helpers.js:16:16)
    at Object.<anonymous> (C:\Users\talon\OneDrive\Desktop\focus\node_modules\cap\lib\Cap.js:3:13)

I am getting this error when I try to run my code, can someone please explain?

btw this is the repository that I am working in: https://github.com/talonbragg/focus

to reproduce the error just run the script start with $ npm start. The code that is running on this command is src/main.js

You need to rebuild/reinstall cap to match the newer version of Electron that you're using.

I did that, then I re-ran the app and still got the same error. Here is my package.json if that helps:

{
  "name": "focus",
  "version": "0.0.1",
  "description": "An app that keeps you on task while you are working",
  "main": "src/main.js",
  "scripts": {
    "start": "electron .",
    "dist": "build"
  },
  "repository": {
    "type": "git",
    "url": "git+https://github.com/talonbragg/focus.git"
  },
  "keywords": [
    "focus"
  ],
  "author": "Talon Bragg",
  "license": "MIT",
  "bugs": {
    "url": "https://github.com/talonbragg/focus/issues"
  },
  "homepage": "https://github.com/talonbragg/focus#readme",
  "devDependencies": {
    "electron": "^6.0.0",
    "electron-builder": "^20.44.4"
  },
  "dependencies": {
    "cap": "^0.2.1",
    "chalk": "^2.4.2",
    "ejs-electron": "^2.0.3",
    "http-proxy": "^1.17.0",
    "node-notifier": "^5.4.0",
    "ping": "^0.2.2"
  }
}

Edit: If there is a specific command I need to use to do this can you please comment it, the command I ran was npm rebuild cap.

No, you have to use Electron's own build commands for Electron projects. npm rebuild cap will build against plain node, which will not build addons that are compatible with Electron. See Electron's native modules guide.

Thank you this helped! Just for reference if anyone is having the same issues, here are the commands you need to run that come from the link provided by @mscdex:

npm install --save-dev electron-rebuild

# Every time you run "npm install", run this:
./node_modules/.bin/electron-rebuild

# On Windows if you have trouble, try:
.\node_modules\.bin\electron-rebuild.cmd

I had the error

was compiled against a different Node.js version using
NODE_MODULE_VERSION 48. This version of Node.js requires
NODE_MODULE_VERSION 73. Please try re-compiling or re-installing
the module

for a similar sort of package (zeromq).

I tried npx electron-rebuild and npm rebuild and then the error changed to

was compiled against a different Node.js version using
NODE_MODULE_VERSION 72. This version of Node.js requires
NODE_MODULE_VERSION 73. Please try re-compiling or re-installing
the module

This seems weird. Normally, such steps fix the issue.

I tried looking at the Node ABI releases, it only goes up to 72. What is this stuff about 73? Any ideas?

@trusktr The full ABI version registry is here. As you can see from the data, the NODE_MODULE_VERSION of 73 is used by Electron 6.

You may need to delete the build directories of the addons you're using. Then recompile using the appropriate Electron-based build tool and there shouldn't be any conflict. Also note that a npm rebuild will use your local node installation and not Electron. Addons compiled for node will not work in Electron and vice-versa. You have to both compile and use the addon on the same platform.

I see, thanks for pointing that out!

I get it now: npm rebuild uses my local node (ABI 72), which isn't what electron has.

The question is, how can I get electron rebuild to work? I have the latest electron-rebuild, v 1.8.6.

This is what I've tried so far:

  • If I run npx electron-rebuild right now, then run Electron, I get the same 72 vs 73 error.
  • If I then remove node_modules and npm install, then the error becomes 48 vs 73.
  • If I then downgrade electron to ^5, re-install node_modules, error goes to 47 vs 70.
  • If I then run electron-rebuild, no change. 47 vs 70
  • If I then run npm rebuild, it goes to 72 vs 70 (seems to make sense, my node is v12, Electron v5 expects a lower ABI version).

Thanks for the help!

If you're having issues with compiling/using addons with Electron, you will need to post an issue on their issue tracker, as they can help more than I.

Opened a new issue there. Thanks!

I had this same problem except it was saying conflicts between 72 and 70.

FIX: uninstalled my current version of Visual Studio Installer, and installed VS Build Tools 2019 (C++) and all the errors went away - even the ones that mentioned seemingly irrelevant things, like issues with NodeJS's serialport package and the Electron dialog import.

fzn0x commented

npm rebuild <package-name> may solve your issue , i try it also when got the same error on bcrypt module

Help me out please !!

Error: The module '/home/runner/Alyx-1/node_modules/better-sqlite3/build/Release/better_sqlite3.node'
was compiled against a different Node.js version using
NODE_MODULE_VERSION 93. This version of Node.js requires
NODE_MODULE_VERSION 72. Please try re-compiling or re-installing
the module (for instance, using npm rebuild or npm install).