Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Problem adding sqlite3 to project #8

Open
jugglingcats opened this issue Feb 21, 2016 · 3 comments
Open

Problem adding sqlite3 to project #8

jugglingcats opened this issue Feb 21, 2016 · 3 comments

Comments

@jugglingcats
Copy link

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.

@rdpascua
Copy link

@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

@thomascayne
Copy link

@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?

@parthvpatel
Copy link

@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?

@vanchisel i'm having this issue while doing project in electron and angular v6. i want to use sqlite3 to store data

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants