DEV Community

foxgem
foxgem

Posted on

Troubleshooting: compiled against a different Node version

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)

Enter fullscreen mode Exit fullscreen mode

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 add scripts to.
    "rebuild": "electron-rebuild -f -w better-sqlit3",
Enter fullscreen mode Exit fullscreen mode
  • npm i
  • npm rebuild

Reference link:

Top comments (0)