Blog

Creating Desktop App With Ember, ExpressJS, Sqlite3 Database and Node-WebKit

Assumptions:

  • Frontend is Ember and backend is Express.
  • NW (node-webkit) version is 0.20.1 (install using npm install -g nw@0.20.1)
  • Node (node) version is 7.0.0 (install using nvm install v7.0.0 which internally download node-sass with file node-v51-linux-x64)
  • NW-gyp (nw-gyp) (install using npm install -g nw-gyp used for building node-webkit from source, but by default it uses latest node version for compilation. In my case it uses v7.0.0. Due to it I upgraded my
    project node version to node v7.0.0)
  • Frontend compiles ember project and store compiled index file to backend/public/index.html

Initial Setup

cd /home/ubuntu/project_name/backend
nvm install v7.0.0
nvm list
nvm use v7.0.0
npm install -g nw@0.20.1
npm install -g nw-gyp

Nodemon is used for running backend express server using nodemon --exec 'bin/www' in backend
npm install -g nodemon

Install npm packages mentioned in package.json
npm install

As by default sqlite is fetched with compiled for node. And as we require to compile for node-webkit so uninstall sqlite3
npm uninstall sqlite3 --save

Compile sqlite3 for runtime as node-webkit with target architecture is of 64 bit system and target version of node-webkit as 0.20.1
npm install sqlite3 --build-from-source --runtime=node-webkit --target_arch=x64 --target=0.20.1 --save

Move sqlite compiled node file from node-webkit-v0.20.1-linux-x64 to node-v51-linux-x64
mv /home/ubuntu/project_name/backend/node_modules/sqlite3/lib/binding/node-webkit-v0.20.1-linux-x64/node_sqlite3.node
/home/ubuntu/project_name/backend/node_modules/sqlite3/lib/binding/node-v51-linux-x64/node_sqlite3.node

In package.json file add following fields
In backend package.json

{
   "main": "http://localhost:3000",
   "node-main": "./bin/www"
}

To run node webkit for current project execute nw

By – Trilok Sharma, Team Lead

adminCreating Desktop App With Ember, ExpressJS, Sqlite3 Database and Node-WebKit
Share this post

Join the conversation

Related Posts