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

Error when adding sqlite3: You may need an appropriate loader to handle this file type. #1155

Closed
aguynamedben opened this issue Jul 28, 2017 · 3 comments

Comments

@aguynamedben
Copy link

Thanks for this excellent project. I've been using it a lot the past 6-8 to learn Electron+React.

I want to store a lot of data in the client, so I'm trying to add sqlite3 to the project. I'm trying to do what is done in electron-boilerplate-sqlite. I understand to some degree that in order to use sqlite3 with Electron, electron-builder must be used, which uses node-pre-gyp somehow to build the sqlite3 bindings.

First, I add sqlite3 to the project:

yarn add sqlite3

It appears that sqlite3 installs correctly. "sqlite3": "^3.1.8", is added to my package.json, but when the postinstall step runs (which critically includes the electron-builder install-app-deps command), I see the following errors:

[1] ERROR in ./node_modules/sqlite3/node_modules/node-pre-gyp/lib/info.js
[1] Module not found: Error: Can't resolve 'aws-sdk' in '/Users/ben/code/tesla/node_modules/sqlite3/node_modules/node-pre-gyp/lib'
[1]  @ ./node_modules/sqlite3/node_modules/node-pre-gyp/lib/info.js 14:14-32
[1]  @ ./node_modules/sqlite3/node_modules/node-pre-gyp/lib ^\.\/.*$
[1]  @ ./node_modules/sqlite3/node_modules/node-pre-gyp/lib/node-pre-gyp.js
[1]  @ ./node_modules/sqlite3/lib/sqlite3.js
[1]  @ dll renderer
[1]
[1] ERROR in ./node_modules/sqlite3/node_modules/node-pre-gyp/lib/publish.js
[1] Module not found: Error: Can't resolve 'aws-sdk' in '/Users/ben/code/tesla/node_modules/sqlite3/node_modules/node-pre-gyp/lib'
[1]  @ ./node_modules/sqlite3/node_modules/node-pre-gyp/lib/publish.js 17:14-32
[1]  @ ./node_modules/sqlite3/node_modules/node-pre-gyp/lib ^\.\/.*$
[1]  @ ./node_modules/sqlite3/node_modules/node-pre-gyp/lib/node-pre-gyp.js
[1]  @ ./node_modules/sqlite3/lib/sqlite3.js
[1]  @ dll renderer
[1]
[1] ERROR in ./node_modules/sqlite3/node_modules/node-pre-gyp/lib/unpublish.js
[1] Module not found: Error: Can't resolve 'aws-sdk' in '/Users/ben/code/tesla/node_modules/sqlite3/node_modules/node-pre-gyp/lib'
[1]  @ ./node_modules/sqlite3/node_modules/node-pre-gyp/lib/unpublish.js 15:14-32
[1]  @ ./node_modules/sqlite3/node_modules/node-pre-gyp/lib ^\.\/.*$
[1]  @ ./node_modules/sqlite3/node_modules/node-pre-gyp/lib/node-pre-gyp.js
[1]  @ ./node_modules/sqlite3/lib/sqlite3.js
[1]  @ dll renderer
[1]
[1] ERROR in ./node_modules/sqlite3/node_modules/node-pre-gyp/node_modules/rc/index.js
[1] Module parse failed: /Users/ben/code/tesla/node_modules/sqlite3/node_modules/node-pre-gyp/node_modules/rc/index.js Unexpected character '#' (1:0)
[1] You may need an appropriate loader to handle this file type.
[1] | #! /usr/bin/env node
[1] | var cc   = require('./lib/utils')
[1] | var join = require('path').join
[1]  @ ./node_modules/sqlite3/node_modules/node-pre-gyp/lib/info.js 11:13-26
[1]  @ ./node_modules/sqlite3/node_modules/node-pre-gyp/lib ^\.\/.*$
[1]  @ ./node_modules/sqlite3/node_modules/node-pre-gyp/lib/node-pre-gyp.js
[1]  @ ./node_modules/sqlite3/lib/sqlite3.js
[1]  @ dll renderer
[1] npm
[1]  ERR! code ELIFECYCLE
[1] npm ERR! errno 2
[1] npm ERR! electron-react-boilerplate@0.12.0 build-dll: `cross-env NODE_ENV=development node --trace-warnings -r babel-register ./node_modules/webpack/bin/webpack --config webpack.config.renderer.dev.dll.js --colors`
[1] npm ERR! Exit status 2
[1] npm ERR!
[1] npm ERR! Failed at the electron-react-boilerplate@0.12.0 build-dll script.
[1] npm ERR! This is probably not a problem with npm. There is likely additional logging output above.

If I isolate the the electron-builder step to it's own action...

    "postinstall-electron-builder": "electron-builder install-app-deps",

and run npm run postinstall-electron-builder, electron-builder seems to run fine.

I think there is some incompatibility between Webpack, node-pre-gyp, concurrently, and/or sqlite3 that is keeping the postinstall step from running correctly. Maybe it is something related to webpack/webpack#4603, where a CLI tool is being bundled.

I'd appreciate any ideas or guidance you could offer in correctly getting sqlite3 working with this project. Thanks for your time.

@aguynamedben aguynamedben changed the title Error when adding sqlite3: Error when adding sqlite3: You may need an appropriate loader to handle this file type. Jul 28, 2017
@aguynamedben
Copy link
Author

A similar error was encountered here: gundb/sqlite#4 but it looks like they never figured out the cause and instead settled on a workaround.

@amilajack
Copy link
Member

amilajack commented Jul 29, 2017

Here's the docs for using native dependencies with this boilerplate

Here's an example of the boilerplate with sqlite.

@aguynamedben
Copy link
Author

@amilajack Thank you, I skipped over the part in the README about how the project has 2 different package.json files, sorry about that. I also didn't realize there were wiki docs too. Thanks so much for pointing me in the right direction.

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

2 participants