I\'m trying to use sequelize and sqlite with electron in a desktop application but get the following error when running the app via npm start
(which runs node
Finally I found a working solution to this problem, based on article provided by @Josh, and other blog posts and issue discussions. Below I wrote all steps I have taken in order to solve this problem. The final solution is posted on the bottom of this answer
I followed electron tutorial available in electron repo.
The Easy Way
I've installed electron-rebuild
node package and run ./node_modules/.bin/electron-rebuild
which gave me the following error:
node-pre-gyp ERR! install error
node-pre-gyp ERR! stack Error: Unsupported target version: 0.31.2
node-pre-gyp ERR! command "node" "/my/project/dir/node_modules/sqlite3/node_modules/.bin/node-pre-gyp" "install" "--fallback-to-build"
node-pre-gyp ERR! not ok
npm ERR! Failed at the sqlite3@3.0.10 install script 'node-pre-gyp install --fallback-to-build'.
npm ERR! This is most likely a problem with the sqlite3 package,
npm ERR! not with npm itself.
npm ERR! Tell the author that this fails on your system:
npm ERR! node-pre-gyp install --fallback-to-build
The node-gyp Way
I've installed node-gyp module globally and entered ./node_modules/sqlite3
dir. Then I tried to run the following command:
node-gyp rebuild --target=0.31.2 --arch=x64 --dist-url=https://atom.io/download/atom-shell
and got the following error:
gyp: Undefined variable module_name in binding.gyp while trying to load binding.gyp
The npm Way
This resulted in the same results as The Easy Way.
The sqlite3 forks
Finally I tried to download few of the sqlite3 forks. Unfortunately results were the same.
Final attempt - The solution
The blog post provided by @Josh was forbidden for me, but I found google cached version of it. I also followed the discussion of the electron issue.
Steps presented below should get you a working sqlite3 package.
"electron-prebuilt": "0.29.1"
electron-prebuilt
./node_modules/sqlite3
npm run prepublish
Configure node-gyp module_name and module_path
node-gyp configure --module_name=node_sqlite3 --module_path=../lib/binding/node-v44-linux-x64
Rebuild package
node-gyp rebuild --target=0.29.1 --arch=x64 --target_platform=linux --dist-url=https://atom.io/download/atom-shell --module_name=node_sqlite3 --module_path=../lib/binding/node-v44-linux-x64
I tried to compile using version 0.31.2 of electron-prebuilt package, but it failed for some reason.
If you are using mac replace linux
with darwin
.
If your os architecture is 32 bit replace x64
with ia32