Troubleshooting: compiled against a different Node version
foxgem
Posted on December 20, 2022
Symptom
Running a node project with the dependency on Better Sqlite3 got the following error message:
Error: The module '... /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 93. Please try re-compiling or re-installing
the module (for instance, using `npm rebuild` or `npm install`).
' the module (for instance, using `npm rebuild` or `npm install`).
' bindings (node_modules/bindings/bindings.js:112:48)
Cause
The error message itself contains enough details, also shows the cause and solution.
In short: the node version used to compile the installed better_sqlite3
is not the same as the node version currently used, so it asks to recompile it with the current version.
Solution
-
npm i -D electron-rebuild
. - Delete the
node_modules
directory. - In
package.json
addscripts
to.
"rebuild": "electron-rebuild -f -w better-sqlit3",
npm i
npm rebuild
Reference link:
💖 💪 🙅 🚩
foxgem
Posted on December 20, 2022
Join Our Newsletter. No Spam, Only the good stuff.
Sign up to receive the latest update from our blog.