package.json
"name": "billingapp",
"version": "1.0.0",
"description": "",
"main": "index.js",
"scripts": {
"rebuild": "electron-rebuild -f -w billingapp"
},
"author": "S Kundu",
"license": "ISC",
"dependencies": {
"electron": "^1.7.11",
"sqlite3": "^3.1.13"
}
"devDependencies": {
"electron-rebuild": "^1.7.3"
}
index.js
const electron = require('electron');
const path = require('path');
const url = require('url');
var sqlite3 = require('sqlite3').verbose();
var db = new sqlite3.Database(path.join(__dirname, 'sample.db'));
const {app, BrowserWindow, Menu, ipcMain} = electron;
let mainWindow;
app.on('ready', function(){
// Create the login window
mainWindow = new BrowserWindow({
resizable: true,
fullscreen: false
});
// Load html in window
mainWindow.loadURL(url.format({
pathname: path.join(__dirname, 'login.html'),
protocol: 'file:',
slashes: true
}));
});
login.html
<h1>Welcome to billing system</h1>
These are the code files.
Steps to install NPM Packages
npm install electron
npm install sqlite3
Its working perfect when I remove bellow code:
var sqlite3 = require('sqlite3').verbose();
var db = new sqlite3.Database(path.join(__dirname, 'sample.db'));
But with this code , while running
npm start
is getting bellow error:
App threw an error during load
Error: Cannot find module 'C:\Users\sintu\Desktop\BillingSystem\node_modules\sqlite3\lib\binding\electron-v1.7-win32-x64\node_sqlite3.node' at Module._resolveFilename (module.js:470:15) at Function.Module._resolveFilename (C:\Users\sintu\Desktop\BillingSystem\node_modules\electron\dist\resources\electron.asar\common\reset-search-paths.js:35:12) at Function.Module._load (module.js:418:25) at Module.require (module.js:498:17) at require (internal/module.js:20:19) at Object. (C:\Users\sintu\Desktop\BillingSystem\node_modules\sqlite3\lib\sqlite3.js:4:15) at Object. (C:\Users\sintu\Desktop\BillingSystem\node_modules\sqlite3\lib\sqlite3.js:190:3) at Module._compile (module.js:571:32) at Object.Module._extensions..js (module.js:580:10) at Module.load (module.js:488:32)
when I run npm run rebuild , I get bellow error
× Rebuild Failed
An unhandled error occurred inside electron-rebuild
Building the projects in this solution one at a time. To enable parallel build, please add the "/m" switch.
C:\Users\sintu\Desktop\billingApp\node_modules\sqlite3\build\deps\action_before_build.vcxproj(20,3): error MSB4019: The imported project "C:\Microsoft.Cpp.Default.props" was not found. Confirm that the path in the declaration is correct, and that the file exists on disk.
gyp ERR! build error
gyp ERR! stack Error: C:\Windows\Microsoft.NET\Framework\v4.0.30319\msbuild.exe
failed with exit code: 1
gyp ERR! stack at ChildProcess.onExit (C:\Users\sintu\Desktop\billingApp\node_modules\node-gyp\lib\build.js:258:23)
gyp ERR! stack at emitTwo (events.js:126:13)
gyp ERR! stack at ChildProcess.emit (events.js:214:7)
gyp ERR! stack at Process.ChildProcess._handle.onexit (internal/child_process.js:198:12)
gyp ERR! System Windows_NT 6.1.7601
gyp ERR! command "C:\Program Files\nodejs\node.exe" "C:\Users\sintu\Desktop\billingApp\node_modules\node-gyp\bin\node-gyp.js" "rebuild" "--target=1.7.11" "--arch=x64" "--dist-url=https://atom.io/download/electron" "--build-from-source" "--module_name=node_sqlite3" "--module_path=C:\Users\sintu\Desktop\billingApp\node_modules\sqlite3\lib\binding\electron-v1.7-win32-x64" "--host=https://mapbox-node-binary.s3.amazonaws.com" "--remote_path=./{name}/v3.1.13/{toolset}/" "--package_name=electron-v1.7-win32-x64.tar.gz"
gyp ERR! cwd C:\Users\sintu\Desktop\billingApp\node_modules\sqlite3
gyp ERR! node -v v8.9.1
gyp ERR! node-gyp -v v3.6.2
gyp ERR! not ok
Failed with exit code: 1
Error: Building the projects in this solution one at a time. To enable parallel build, please add the "/m" switch.
C:\Users\sintu\Desktop\billingApp\node_modules\sqlite3\build\deps\action_before_build.vcxproj(20,3): error MSB4019: The imported project "C:\Microsoft.Cpp.Default.props" was not found. Confirm that the path in the declaration is correct, and that the file exists on disk.
gyp ERR! build error
gyp ERR! stack Error: C:\Windows\Microsoft.NET\Framework\v4.0.30319\msbuild.exe
failed with exit code: 1
gyp ERR! stack at ChildProcess.onExit (C:\Users\sintu\Desktop\billingApp\node_modules\node-gyp\lib\build.js:258:23)
gyp ERR! stack at emitTwo (events.js:126:13)
gyp ERR! stack at ChildProcess.emit (events.js:214:7)
gyp ERR! stack at Process.ChildProcess._handle.onexit (internal/child_process.js:198:12)
gyp ERR! System Windows_NT 6.1.7601
gyp ERR! command "C:\Program Files\nodejs\node.exe" "C:\Users\sintu\Desktop\billingApp\node_modules\node-gyp\bin\node-gyp.js" "rebuild" "--target=1.7.11" "--arch=x64" "--dist-url=https://atom.io/download/electron" "--build-from-source" "--module_name=node_sqlite3" "--module_path=C:\Users\sintu\Desktop\billingApp\node_modules\sqlite3\lib\binding\electron-v1.7-win32-x64" "--host=https://mapbox-node-binary.s3.amazonaws.com" "--remote_path=./{name}/v3.1.13/{toolset}/" "--package_name=electron-v1.7-win32-x64.tar.gz"
gyp ERR! cwd C:\Users\sintu\Desktop\billingApp\node_modules\sqlite3
gyp ERR! node -v v8.9.1
gyp ERR! node-gyp -v v3.6.2
gyp ERR! not ok
Failed with exit code: 1
at SafeSubscriber._error (C:\Users\sintu\Desktop\billingApp\node_modules\spawn-rx\lib\src\index.js:277:84)
at SafeSubscriber.__tryOrUnsub (C:\Users\sintu\Desktop\billingApp\node_modules\rxjs\Subscriber.js:239:16)
at SafeSubscriber.error (C:\Users\sintu\Desktop\billingApp\node_modules\rxjs\Subscriber.js:198:26)
at Subscriber._error (C:\Users\sintu\Desktop\billingApp\node_modules\rxjs\Subscriber.js:129:26)
at Subscriber.error (C:\Users\sintu\Desktop\billingApp\node_modules\rxjs\Subscriber.js:103:18)
at MapSubscriber.Subscriber._error (C:\Users\sintu\Desktop\billingApp\node_modules\rxjs\Subscriber.js:129:26)
at MapSubscriber.Subscriber.error (C:\Users\sintu\Desktop\billingApp\node_modules\rxjs\Subscriber.js:103:18)
at SafeSubscriber._next (C:\Users\sintu\Desktop\billingApp\node_modules\spawn-rx\lib\src\index.js:251:65)
at SafeSubscriber.__tryOrUnsub (C:\Users\sintu\Desktop\billingApp\node_modules\rxjs\Subscriber.js:239:16)
at SafeSubscriber.next (C:\Users\sintu\Desktop\billingApp\node_modules\rxjs\Subscriber.js:186:22)
npm ERR! code ELIFECYCLE
npm ERR! errno 4294967295
npm ERR! [email protected] rebuild: electron-rebuild -f -w billingapp
npm ERR! Exit status 4294967295
npm ERR!
npm ERR! Failed at the [email protected] rebuild script.
npm ERR! This is probably not a problem with npm. There is likely additional logging output above.
npm ERR! A complete log of this run can be found in: npm ERR! C:\Users\sintu\AppData\Roaming\npm-cache_logs\2018-01-30T15_36_46_678Z-debug.log
it seems you have many problems with your scripts, but you also encountered a rare issue with sqlite.
0) You can find my Github source here that is working until this error :
Cannot read property 'on' of undefined
but that is another problem :D
1) Your package.json is not well formated (there is no start script for example)
New package.json
{ // there was no begining bracket
"name": "billingapp",
"version": "1.0.0",
"description": "",
"main": "index.js",
"scripts": {
"rebuild": "electron-rebuild -f -w billingapp",
"start": "node index.js" // new start script
},
"author": "S Kundu",
"license": "ISC",
"dependencies": {
"electron": "^1.7.11",
"sqlite3": "^3.1.0" // I used this version
},
"devDependencies": {
"electron-rebuild": "^1.7.3"
}
}
2) When I installed sqlite I encountered this issue https://github.com/mapbox/node-sqlite3/issues/758
It seems sqlite3 is not working with the last version of nodejs, so you need to install [email protected] you can use nvm for that:
see comment on sqlite3 issue
treedbox commented on 20 Dec 2017
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With