angular2-electron
angular2-electron copied to clipboard
Problem adding sqlite3 to project
Apologies if this is not directly related to angular2-electron, but I spent quite a bit of time looking for a fix and couldn't find one. I'm new to webpack and electron.
I tried adding sqlite3 to the project and requiring it:
npm install sqlite3 -S
app.ts
var sql=require("sqlite3")
but the build fails with a lot of warnings and finally an error, eg:
WARNING in ./~/sqlite3/lib/sqlite3.js
Critical dependencies:
4:14-35 the request of a dependency is an expression
@ ./~/sqlite3/lib/sqlite3.js 4:14-35
WARNING in ./~/sqlite3/~/node-pre-gyp/lib/util/nw-pre-gyp/index.html
Module parse failed: xxxxx\angular2-electron\node_modules\sqlite3\node_modules\node-pre-gyp\lib\util\nw-pre-gyp\index.html Line 1: Unexpected token <
You may need an appropriate loader to handle this file type.
| <!doctype html>
| <html>
| <head>
@ ./~/sqlite3/~/node-pre-gyp/lib ^\.\/.*$
WARNING in ./~/sqlite3/~/node-pre-gyp/lib/util/compile.js
Module not found: Error: Cannot resolve module 'node-gyp'
ERROR in ./~/sqlite3/~/node-pre-gyp/~/rc/index.js
Module parse failed: xxxxx\angular2-electron\node_modules\sqlite3\node_modules\node-pre-gyp\node_modules\rc\index.js Line 1: Unexpected token ILLEGAL
You may need an appropriate loader to handle this file type.
| #! /usr/bin/env node
| var cc = require('./lib/utils')
| var join = require('path').join
@ ./~/sqlite3/~/node-pre-gyp/lib/info.js 11:13-26```
I am pretty sure this is something to do with sqlite3 having native code, but am not sure how to fix this in a webpack/electron build.
Any help/pointers appreciated.
@jugglingcats did you find any solution to this issue?
What I did is added sqlite3
to the externals in webpack configuration. But still doesn't work
@rdpascua did you find a solution for this? I did a project in electron
with javascript requiring sqlite3
. There was a lot of conflicts and I abandoned sqlite3 for [sql.js]
(https://github.com/kripken/sql.js) and [sync-sqlite](https://github.com/Spikef/sync-sqlite)
. Both work very well separately.
Now, I'm doing another project in electron
and angular and requires sqlite but finding sql.js/sync-sqlite
isues. I'll try sqlite3
tonight. What did you use?
@rdpascua did you find a solution for this? I did a project in
electron
with javascript requiringsqlite3
. There was a lot of conflicts and I abandoned sqlite3 for[sql.js]
(https://github.com/kripken/sql.js) and[sync-sqlite](https://github.com/Spikef/sync-sqlite)
. Both work very well separately.Now, I'm doing another project in
electron
and angular and requires sqlite but findingsql.js/sync-sqlite
isues. I'll trysqlite3
tonight. What did you use?
@vanchisel i'm having this issue while doing project in electron
and angular v6
. i want to use sqlite3
to store data