Make ElectronJS work with SQLite3

Moved to :


I write this blog just because I’ve spent quite some time… um hum… I mean days and nights and was having a freaking headache just to make SQLite3 work with ElectronJS. I couldn’t find the solution, neither on Github nor Stackoverflow (Peace and Love bro!). I’ve found the solution by myself!

Image result for gif love you bro
StackOverflow, some friendship never ends….

Sqlite3 has some issues with native modules of ElectronJS, when doing simply:

npm install --save sqlite3

It simply doesn’t work! But you are here because of that I guess or out of curiosity! let’s go quickly to your needs!

QUICK NOTE: Using Mono on Linux (or Mac) is enough, skip the Windows part and jump to step 6.


1. Run Windows PowerShell as Administrator and run this:

npm install --global --production windows-build-tools  and wait for it to finish completely, it will take a bit long.

If you are running in some kind of issue:


copy and set this as your PATH in your Environment System Variables.

2. Double check if all is installed, and the most important part is Visual C++ Build Environment. To do so;  download the Visual C++ Build Tools.  You will be prompted to download files, just choose: Build Tools for Visual Studio 2017, it can be 2017 or greater depending when you read this post. But for the time being you will find this:

It can be 2017 or greater

3. Open and Install, you will find this:


4. Don’t worry if it is installed or not, because what we need to verify is that VC++ is checked; to do so click on Modify Button. This will shows up:


On the right corner, you will see VC++ 2015V14.00. Just check it! And Click on modify to install it.

5. Execute npm config set python python2.7 and npm config set msvs_version 2017 on CMD.

6. Just install this package:

npm install --save-dev electron-rebuild

Add these two lines under scripts in your package.json


Figure 0 (because programmers counts from zero, remember ?)


7. This will simply build native node modules with your app. To do so, write this run:

But make sure you did step 5. It’s important.

npm run rebuild

Afterwards, you can do this below to run your app. It will run Electron flawlessly with your app but it doesn’t end here…

 electron .

8. Now you will try package your app, and make an executable, but no! Don’t do that yet, you will need to make a file a special file  in which you will integrate it to your Electron Packager, just use this below and call it build.js if you want and place it at the same directory level of package.json:

If you haven’t installed electron-package:

npm install --save-dev electron-packager

And add this to the file:

const packager = require('electron-packager');
const rebuild = require('electron-rebuild');

    dir: './',
    overwrite: true,
    asar: true,
    platform: 'win32',
    arch: 'ia32',
    prune: true,
    out: 'release-builds-folder',
    executableName: 'my-app',
    icon: 'icon/myicon.ico',

    afterCopy: [(buildPath, electronVersion, platform, arch, callback) => {

    rebuild.rebuild({ buildPath, electronVersion, arch })

      .then(() => callback())

      .catch((error) => callback(error));



As mentioned in Figure 0, this build.js file needs to be executed to  package your app:

npm run package-rebuild

And now, you have SQLite3 working fine with Electron + you can package your app without an issue!


Image result for relieved meme gif
Now feel relieved, dear brothas and sistas !


If you have questions, please feel free to ask, and don’t forget to share ! Stay tuned on



  1. Hi
    thanks for you post it got me further than any other site. i try for months to make works electron and sqlite on windows. But I got an error on step 7

    npm run rebuild /m

    > t5@1.0.0 rebuild D:\Electron\t5
    > electron-rebuild -f -w sqlite3 “/m”

    × Rebuild Failed

    An unhandled error occurred inside electron-rebuild
    Building the projects in this solution one at a time. To enable parallel build, please add the “/m” switch.
    ‘python2.7’ is not recognized as an internal or external command,
    operable program or batch file.
    C:\Program Files (x86)\MSBuild\Microsoft.Cpp\v4.0\V140\Microsoft.CppCommon.targets(171,5): error MSB6006: “cmd.exe” exited with code 1.

    But I have the version 2.7 of python installed
    >npm config get python

    And I didn’t forgot the step 5…

    Any idea why I got this error ?



    • Hello, if you have python installed, can you check if it is globally accessible, i.e when u type python2.7 on cmd directly it is accessible directly.

      try this and let me know

      Below is a method to install Python 2.7 on Windows, using the Python distribution from Please note that THERE ARE EASIER WAYS THAN THIS. E.g. you can use the Anaconda distribution, which is one click, and has a nice windows installer. To do that, ignore everything below and just click here:

      If for some reason you want to do it the slightly harder way:

      1. Install Python
        Download the Python installer from here: Make sure you download version 2.7. The instructions that follow assume you have installed python in its default folder, which is c:\Python27.

      2. Update your “PATH”
        Once python is installed you’ll need to update your “PATH”, so that your computer can find Python. How you do this depends on your operating system:

      On Windows 7

      1. Select “Computer” from the Start menu

      2. Choose “System Properties” from the menu

      3. Click “Advanced system settings” (it’s on the left) then click the “Advanced” tab

      4. Click on “Environment Variables”, under “System Variables”, find “Path”, and click on it.

      5. Click “Edit…”, and add the text on the following line to the end of the Path in the box “Variable value”. Note that there should be no spaces anywhere at all:


      then click “OK” and you’re done.

      On Windows XP

      1. Click the “Start” menu, then “Control Panel” -> “System” -> “Advanced”

      2. Click on “Environment Variables”, under “System Variables”, find “Path”, and click on it.

      3. Click “Edit…”, and add the text on the following line to the end of the Path. Note that there should be no spaces anywhere at all:


      then click “OK” and you’re done.

      On Windows Vista

      1. Right click “My Computer” icon

      2. Choose “Properties” from the menu

      3. Click “Advanced” tab (it might also be called “Advanced system settings”)

      4. Click “Edit…”, and add the text on the following line to the end of the Path. Note that there should be no spaces anywhere at all:


      then click “OK” and you’re done.

      view raw
      hosted with ❤ by GitHub

      and thank you very much 🙂


      • Yes, like you taught, the python wasn’t accessible from my cmd windows. I had to reinstall it. After that, the command “python2.7” wasn’t working but “python” worked, so I ran “npm config set python python”
        and all works now…

        thanks a lot.


      • That was fast 🙂 I’m happy I helped, and I know your feeling… I’ve been suffering also with that 🙂

        Don’t forget to share for other who struggle too !


Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

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