javascriptnpmquick.db

npm rebuild doesn't work when trying to fix different node module version error


I'm getting an error where the better_sqlite3 package is using a different version of node, and it says to try npm rebuild and npm install but this doesn't solve anything and I'm still getting the same error.

/home/nonce/Documents/Repositories/test/node_modules/bindings/bindings.js:121
        throw e;
        ^

Error: The module '/home/nonce/Documents/Repositories/test/node_modules/better-sqlite3/build/Release/better_sqlite3.node'
was compiled against a different Node.js version using
NODE_MODULE_VERSION 102. This version of Node.js requires
NODE_MODULE_VERSION 93. Please try re-compiling or re-installing
the module (for instance, using `npm rebuild` or `npm install`).
    at Object.Module._extensions..node (node:internal/modules/cjs/loader:1183:18)
    at Module.load (node:internal/modules/cjs/loader:981:32)
    at Function.Module._load (node:internal/modules/cjs/loader:822:12)
    at Module.require (node:internal/modules/cjs/loader:1005:19)
    at require (node:internal/modules/cjs/helpers:102:18)
    at bindings (/home/nonce/Documents/Repositories/test/node_modules/bindings/bindings.js:112:48)
    at Object.<anonymous> (/home/nonce/Documents/Repositories/test/node_modules/better-sqlite3/lib/database.js:9:24)
    at Module._compile (node:internal/modules/cjs/loader:1101:14)
    at Object.Module._extensions..js (node:internal/modules/cjs/loader:1153:10)
    at Module.load (node:internal/modules/cjs/loader:981:32) {
  code: 'ERR_DLOPEN_FAILED'
}

I don't think this is an error with better-sqlite3 itself, since I've done some research and a lot of people have gotten this sort of error, and the general solution is to execute npm rebuild but for me this doesn't do anything.


Solution

  • Solved the issue, I was using an outdated version of node as I was using node v16.13.2 so I tried switching to the most latest version (v17.4.0 as of now) and it works like a charm now.