I am writing this post to share the information that will be helpful to you to setup the electron and sqlite3 in windows environment.
Setup of electron is quite simple but sqlite3 is some tricky to setup.So to setup electron and sqlite3 with minimum setup is as follows.
Install NodeJs
Install the electron-prebuilt
Install the electron-rebuild as dev dependency
Install the sqlite3
Now it is time to pull node-gyp
node-gyp is a cross-platform command-line tool written in Node.js for compiling native addon modules for Node.js. It bundles the gyp project used by the Chromium team and takes away the pain of dealing with the various differences in build platforms.
For detail node-gyp
Now we have to install build tools consisting python 2.7 and visual c++ dependency so gyp can built our native module. Just run the command shown below and it will pull the necessary files automatically. I recommend to use this.
This command will take lots of time to download files. But don't close until you get message of successful installation of python and visual studio. you might fill that visual studio is not installing but it is installing behind scene. So wait until it finish downloading and installation.
At last check that if your python env variable is set by running python in cmd
At end put this command in your package.json under scripts :
"rebuild": "electron-rebuild -f -w sqlite3"
finally your package.json should look like this.
{
"name": "sqlitetu",
"version": "1.0.0",
"description": "This is the tutorial for the sqllite",
"main": "index.js",
"scripts": {
"test": "echo \"Error: no test specified\" && exit 1",
"start": "electron .",
"rebuild": "electron-rebuild -f -w sqlite3"
},
"author": "",
"license": "ISC",
"dependencies": {
"electron-prebuilt": "^1.4.13",
"sqlite3": "^3.1.8"
},
"devDependencies": {
"electron-rebuild": "^1.5.10"
}
}
In the last setup run the command npm run rebuild and you done.
Hope you find it useful.
This comment has been removed by a blog administrator.
ReplyDeleteWhat error you get?
Delete