Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

better_sqlite3 was compiled against a different Node.js version #549

Closed
D3dWiz opened this issue Jan 29, 2021 · 12 comments
Closed

better_sqlite3 was compiled against a different Node.js version #549

D3dWiz opened this issue Jan 29, 2021 · 12 comments

Comments

@D3dWiz
Copy link

D3dWiz commented Jan 29, 2021

Error: The module 'path\node_modules\better-sqlite3\build\Release\better_sqlite3.node'
was compiled against a different Node.js version using
NODE_MODULE_VERSION 83. 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).

tried everything, any ideas?

@adamgen
Copy link

adamgen commented Feb 3, 2021

I get the same error...

@i-chaochen
Copy link

Met the same problem, you need to rebuild and postinstall

In my package.json

  "scripts": {
    "start": "electron .",
    "rebuild": "electron-rebuild -f -w better-sqlite3",
    "postinstall": "electron-builder install-app-deps"
  },

@D3dWiz
Copy link
Author

D3dWiz commented Feb 14, 2021

I couldn't fix it but I had to reinstall my PC the next week and the second time I tried installing it it worked.
I'll leave the issue open since other people still have problems.

@itbalance
Copy link

Credit goes to https://stackoverflow.com/users/3712591/chitzui, I'm just re-posting here because this worked for me -

From: https://stackoverflow.com/questions/46384591/node-was-compiled-against-a-different-node-js-version-using-node-module-version
I had the same problem and nothing mentioned here worked for me. Here is what worked for me:

Require all dependencies you need in the main.js file that is run by electron. (this seemed to be the first important part for me)
1- npm i -D electron-rebuild to add the electron-rebuild package
2- Remove the node-modules folder, as well as the packages-lock.json file.
3- npm i to install all modules.
4- Run ./node_modules/.bin/electron-rebuild to rebuild everything

It is very important to run ./node_modules/.bin/electron-rebuild directly after npm i otherwise it did not work on my mac.

@JoshuaWise
Copy link
Member

Duplicate of #545

@JoshuaWise JoshuaWise marked this as a duplicate of #545 Mar 31, 2021
@quantuminformation
Copy link

why is there dep on electron?

@ahoys
Copy link

ahoys commented Nov 10, 2023

I'll comment here because this was the first Google result about the subject.

I had long lasting issues getting the better-sqlite3 rebuilding to work on Windows 11 and electron-forge. Finally, this was the package.json npm-script that worked:
"rebuild": ".\\node_modules\\.bin\\electron-rebuild.cmd -f -m ./node_modules/better-sqlite3"

Run this with npm run rebuild, not npm rebuild

You don't have to have the rebuild library installed as it is part of electron-forge.

If the rebuild process finishes immediately, it most likely did not do anything despite claiming that the process was a success. This threw me off. The goal is to rebuild what's found in node_modules/better-sqlite3, so go and see if the files have actually been changed.

The CLI arguments found from rebuild repo are valuable when debugging the issue.

@clintharris
Copy link

I found that the electron-rebuild command only worked when I used the -m {path to module} flag, as @ahoys suggested.

Not sure, but the fact that my electron app is a sub-project / npm workspace in a monorepo might be related.

@Rehab-Osman
Copy link

I tried npm rebuild better_sqlite3 then npm rebuild after upgrading from node 18 to 20 and working perfect with me

@AlexeiKharchev
Copy link

AlexeiKharchev commented Apr 21, 2024

IMHO, the problem is node_modules/better_sqlite3/build/config.gypi has line
node_module_version": 120,

@viniciusteixeiradias
Copy link

IMHO, the problem is node_modules/better_sqlite3/build/config.gypi has line node_module_version": 120,

Any solution for that?

@runrennerrun
Copy link

I tried npm rebuild better_sqlite3 then npm rebuild after upgrading from node 18 to 20 and working perfect with me

worked for me also 💪

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Development

No branches or pull requests