Introduction

A few months ago I ran into some problems when I tried to use Sequelize with sqlite3 inside an Electron app. Even though I installed everything properly, I was getting this error:

I was able to fix this using this website but it appears to be down now. I decided to write down the method here and also adding a bit more details on how to solve the problem.

Solution

  • Go to node_modules/sequelize/lib/dialects/connection-manager.js and identify the MODULE_NOT_FOUND error code. Log the error with a console.log(err) before the error is thrown.
  • Run the application and you will get a more detailed error:

{ Error: Cannot find module 'C:\Users\Razvan\Documents\devStuff\work\app\server\node_modules\sqlite3\lib\binding\electron-v1.3-win32-x64\node_sqlite3.node'

  • Note the electron-v1.3-win32-x64. You might have something different depending on the electron version you installed
  • cd node_modules/sqlite3 and then run the following:

  • --module_path replace with what you got from the MODULE_NOT_FOUND error
  • --target_platform win32, darwin or linux
  • --arch x64 or ia32
  • --target the version of electron you are using

 

If there are issues on Windows about MSB4019, check this issue https://github.com/brianmcd/contextify/issues/96

That’s all

By following the steps above I managed to make the configuration work on Windows and Mac. Hopefully this solves the problem for you too.

If you still encounter the problem, check this post on stackoverflow. It offers multiple approaches.