Error with wrong API version of node module

Intro

Some npm packages are not pure javascript. If they have some kind of binary, these binaries have to be compiled against the right nodejs version; or else the ABI is wrong. There are precompiled binaries, but sometimes there aren’t or they doesn’t fit the version you need. Especially with electron, which maybe uses different versions…

Problem

Either way, this was the error message

Error: Cannot find module node_modules/sqlite3/lib/binding/node-v57-linux-x64/node_sqlite3.node

while there was a node_sqlite3.node, but in a different /binding subdirectory.

Solution

This stackoverflow post https://stackoverflow.com/a/39463304 has guided me to a package that can rebuild to the correct ABI used: https://github.com/electron/electron-rebuild

npm install –save-dev electron-rebuild
$(npm bin)/electron-rebuild

And that was another problem fixed. Thanks for reading!

Leave a Reply

Your email address will not be published.

This site uses Akismet to reduce spam. Learn how your comment data is processed.