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.
Hi there, I am new to electron. I am facing an issue on running the last command, i.e.
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
I was not able to compile sqlite package for the electron package V1.4.12 and node version v6.9.1 I amusing Windows 7 professional.
The error I am facing is as follows:
Building the projects in this solution one at a time. To enable parallel build,
please add the "/m" switch.
unpack_sqlite_dep
sqlite3.cc
C:\Users\ky29991.node-gyp\iojs-1.4.12\deps\v8\include\v8.h(91) : see
declaration of 'v8::Object'
C:\Users\ky29991.node-gyp\iojs-1.4.12\deps\v8\include\v8.h(3064): error C2989:
'v8::Array' : class template has already been declared as a non-class template
[D:\Nitin\NodeJS\Final91216\electron\NodeJSSQLite\node_modules\sqlite3\build\n
ode_sqlite3.vcxproj]
C:\Users\ky29991.node-gyp\iojs-1.4.12\deps\v8\include\v8.h(71) : see
declaration of 'v8::Array'
C:\Users\ky29991.node-gyp\iojs-1.4.12\deps\v8\include\v8.h(3418): error C2238:
unexpected token(s) preceding ';' [D:\Nitin\NodeJS\Final91216\electron\NodeJSS
QLite\node_modules\sqlite3\build\node_sqlite3.vcxproj]
C:\Users\ky29991.node-gyp\iojs-1.4.12\deps\v8\include\v8.h(3419): error C2143:
syntax error : missing ';' before '<' [D:\Nitin\NodeJS\Final91216\electron\Nod
eJSSQLite\node_modules\sqlite3\build\node_sqlite3.vcxproj]
C:\Users\ky29991.node-gyp\iojs-1.4.12\deps\v8\include\v8.h(3419): error C4430:
missing type specifier - int assumed. Note: C++ does not support default-int [
D:\Nitin\NodeJS\Final91216\electron\NodeJSSQLite\node_modules\sqlite3\build\nod
e_sqlite3.vcxproj]
C:\Users\ky29991.node-gyp\iojs-1.4.12\deps\v8\include\v8.h(3420): error C2238:
unexpected token(s) preceding ';' [D:\Nitin\NodeJS\Final91216\electron\NodeJSS
QLite\node_modules\sqlite3\build\node_sqlite3.vcxproj]
C:\Users\ky29991.node-gyp\iojs-1.4.12\deps\v8\include\v8.h(3428): error C2061:
syntax error : identifier 'Value' [D:\Nitin\NodeJS\Final91216\electron\NodeJSS
QLite\node_modules\sqlite3\build\node_sqlite3.vcxproj]
C:\Users\ky29991.node-gyp\iojs-1.4.12\deps\v8\include\v8.h(3432): error C2061:
syntax error : identifier 'Value' [D:\Nitin\NodeJS\Final91216\electron\NodeJSS
QLite\node_modules\sqlite3\build\node_sqlite3.vcxproj]
C:\Users\ky29991.node-gyp\iojs-1.4.12\deps\v8\include\v8.h(3432): fatal error
C1003: error count exceeds 100; stopping compilation [D:\Nitin\NodeJS\Final9121
6\electron\NodeJSSQLite\node_modules\sqlite3\build\node_sqlite3.vcxproj]
gyp ERR! build error
gyp ERR! stack Error:
C:\Windows\Microsoft.NET\Framework\v4.0.30319\msbuild.exe
failed with exit code: 1gyp ERR! stack at ChildProcess.onExit (C:\Users\ky29991\AppData\Roaming\npm
node_modules\node-gyp\lib\build.js:276:23)
gyp ERR! stack at emitTwo (events.js:106:13)
gyp ERR! stack at ChildProcess.emit (events.js:191:7)
gyp ERR! stack at Process.ChildProcess._handle.onexit (internal/child_proces
s.js:215:12)
gyp ERR! System Windows_NT 6.1.7601
gyp ERR! command "C:\Program Files\nodejs\node.exe" "C:\Users\ky29991\AppD
ata\Roaming\npm\node_modules\node-gyp\bin\node-gyp.js" "rebuild" "--target
=1.4.12" "--arch=x64" "--target_platform=win32" "--dist-url=https://atom.io/down
load/atom-shell" "--module_name=node_sqlite3" "--module_path=../lib/binding/node
-v48-win32-x64"
gyp ERR! cwd D:\Nitin\NodeJS\Final91216\electron\NodeJSSQLite\node_modules\sqlit
e3
gyp ERR! node -v v6.9.1
gyp ERR! node-gyp -v v3.4.0
gyp ERR! not ok
Thanking you,
Nitin Kandpal