This guide is based on the very informative discussion in this article: Using node_sqlite3 with Electron
Install sqlite3
npm install sqlite3 --save
Navigate into the sqlite3 module folder
cd node_modules/sqlite3
Install nan locally into the sqlite3 folder (you will need it for the next step)
npm install nan@~2.1.0 --save
Prebulish the module:
npm run prepublish
Start compilation by setting the module path to the correct version, in this case node-v47-win32-x64
. It is located in your sqlite3 folder.
node-gyp configure --module_name=node_sqlite3 --module_path=../lib/binding/node-v47-win32-x64
Finish compilation by setting your build to the correct target
version. You will find the target
version of your Electron-App in the version
file in the root folder of your Electron directory.
node-gyp rebuild --target=0.36.0 --arch=x64 --target_platform=win32 --dist-url=https://atom.io/download/atom-shell --module_name=node_sqlite3 --module_path=../lib/binding/node-v47-win32-x64
Now you can use sqlite3 in your Electron app.
Thank you for this concise summary. I also was running into electron looking for
electron-v0.37-win32-x64
, but the directory that was getting created under sqlite3 was node-v47-win32-x64. I've spent hours trying to resolve this. I finally came across the original post that you have summarized for windows. I think I kept getting just one thing wrong every time I would try to run various commands. My final process was to install sqlite3 (did not need to install nan, it was already installed there), and then run the 3 command, changing both my electron version and my directories to be electron-v0.37-win32-x64. To find my electron version I used <script>document.write(process.versions.electron)</script> in index.html. thanks again!