DEV Community

foxgem
foxgem

Posted on

4 1

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:

Heroku

Simplify your DevOps and maximize your time.

Since 2007, Heroku has been the go-to platform for developers as it monitors uptime, performance, and infrastructure concerns, allowing you to focus on writing code.

Learn More

Top comments (0)

Billboard image

The Next Generation Developer Platform

Coherence is the first Platform-as-a-Service you can control. Unlike "black-box" platforms that are opinionated about the infra you can deploy, Coherence is powered by CNC, the open-source IaC framework, which offers limitless customization.

Learn more