Electron-forge: Adding sqlite3 dependency breaks packaging of the application.

Created on 5 May 2020  路  2Comments  路  Source: electron-userland/electron-forge

Preflight Checklist

  • [x] I have read the contribution documentation for this project.
  • [x] I agree to follow the code of conduct that this project follows, as appropriate.
  • [x] I have searched the issue tracker for a bug that matches the one I want to file, without success.

Issue Details

  • Electron Forge Version:

    • 6.0.0-beta.51

  • Electron Version:

    • 8.2.5

  • Operating System:

    • OpenSUSE Tumbleweed x64

Expected Behavior

Project is packaged: yarn package results in no error.

Actual Behavior

yarn package fails with error related to sqlite3 module.

Maybe this is more related to sqlite3, but this only happens when using webpack template, I guess something related to renderer configuration. Want to find out (not that much of a JS guy yet).

To Reproduce

# just create simple minimal project with webpack template and sqlite3 dependency.

mkdir my-proj && cd my-proj
electron-forge init --template=webpack
yarn install
yarn add sqlite3
# add import 'sqlite3' line into src/renderer.js
yarn package

Additional Information

native_modules//lib/binding/node-v72-linux-x64/node_sqlite3.node  1.87 MiB          
 native_modules/lib/binding/node-v72-linux-x64/node_sqlite3.node  1.87 MiB          
Entrypoint main_window = main_window/index.js
  [0] external "path" 42 bytes {0} [built]
  [1] external "util" 42 bytes {0} [built]
  [3] external "events" 42 bytes {0} [built]
 [39] multi ./src/renderer.js 28 bytes {0} [built]
 [40] ./src/renderer.js 1010 bytes {0} [built]
 [41] ./src/index.css 1.06 KiB {0} [built]
 [42] ./node_modules/css-loader/dist/cjs.js!./src/index.css 402 bytes {0} [built]
 [43] ./node_modules/css-loader/dist/runtime/api.js 2.46 KiB {0} [built]
 [44] ./node_modules/style-loader/lib/addStyles.js 10.2 KiB {0} [built]
 [45] ./node_modules/style-loader/lib/urls.js 2.94 KiB {0} [built]
 [46] ./node_modules/sqlite3/lib/sqlite3.js 6.16 KiB {0} [built]
 [47] ./node_modules/sqlite3/lib/sqlite3-binding.js 424 bytes {0} [built]
 [48] ./node_modules/node-pre-gyp/lib/node-pre-gyp.js 4.59 KiB {0} [built]
[102] ./node_modules/sqlite3/lib/binding/node-v72-linux-x64/node_sqlite3.node 327 bytes {0} [built]
[104] ./node_modules/sqlite3/lib/trace.js 1.4 KiB {0} [built]
    + 90 hidden modules

ERROR in ./node_modules/node-pre-gyp/lib/node-pre-gyp.js
Module not found: Error: Can't resolve './' in '/home/sherzod/work/socmag/socmag.app/ttt/t1/node_modules/node-pre-gyp/lib'
 @ ./node_modules/node-pre-gyp/lib/node-pre-gyp.js 52:13-32 184:38-57
 @ ./node_modules/sqlite3/lib/sqlite3-binding.js
 @ ./node_modules/sqlite3/lib/sqlite3.js
 @ ./src/renderer.js
 @ multi ./src/renderer.js
Child HtmlWebpackCompiler:
                          Asset      Size  Chunks  Chunk Names
    __child-HtmlWebpackPlugin_0  4.05 KiB       0  HtmlWebpackPlugin_0
    Entrypoint HtmlWebpackPlugin_0 = __child-HtmlWebpackPlugin_0
    [0] ./node_modules/html-webpack-plugin/lib/loader.js!./src/index.html 470 bytes {0} [built]
    at /home/sherzod/work/socmag/socmag.app/ttt/t1/node_modules/@electron-forge/plugin-webpack/src/WebpackPlugin.ts:271:15

This must be closely related to: #575 which was closed without solution: just adding sqlite3 to externals is not good, because eventually we will need to make project, and the result will contain no sqlite3 module.

Bug

Most helpful comment

If anyone still facing the issue, try using better-sqlite3 instead of sqlite3.
Follow regular steps and it should work.

Better sqlite3 7.0.1 solves this issue of binding native module which existed earlier.
Please have a look.

All 2 comments

Facing same problem here. Did you get any solution?

If anyone still facing the issue, try using better-sqlite3 instead of sqlite3.
Follow regular steps and it should work.

Better sqlite3 7.0.1 solves this issue of binding native module which existed earlier.
Please have a look.

Was this page helpful?
0 / 5 - 0 ratings