Make Electron Work with Sqlite3
The other day I tried to integrate knex with a SQLITE3 back-end. Unfortunately, the instant I’ve tried to instantiate knex, I’ve got a lot of errors. After getting rid of them, I found that I can’t get sqlite3 to work at all, even though I’ve checked the installation and it was OK (got the binary downloaded and even rebuilt it).
Uncaught Error: Cannot find module ‘/…/node_modules/sqlite3/lib/binding/node-v51-darwin-x64/node_sqlite3.node’
So, here are the steps that I did to make it work:
- install electron-rebuild
12npm install --save-dev electron-rebuild
- install sqlite3 using npm
12npm install --save sqlite3
- rebuild electron with sqlite3. In
scriptssection, add:12"rebuild": "electron-rebuild -f -w sqlite3"
- run the following command
12npm run rebuild
Now, you’ll get another binding, something like:
which is accepted by electron.
A little experiment: If you find this post and ad below useful, please check the ad out :-)