Node-sqlite3: Compiled binary is fine but can't find module 'node_modules/sqlite3/package.json'

Created on 22 Apr 2018  ·  4Comments  ·  Source: mapbox/node-sqlite3

┏ Electron -------------------

  Error: Cannot find module "/Users/raphaelsoul/Projects/electronApp/node_modules/sqlite3/package.json".
      at webpackEmptyContext (eval at ./node_modules/sqlite3/node_modules/node-pre-gyp/lib sync recursive (/Users/raphaelsoul/Projects/electronApp/dist/main/main.js:12136:1), <anonymous>:2:10)
      at Object.exports.find (webpack-internal:///./node_modules/sqlite3/node_modules/node-pre-gyp/lib/pre-binding.js:20:113)
      at Object.eval (webpack-internal:///./node_modules/sqlite3/lib/sqlite3.js:3:27)
      at eval (webpack-internal:///./node_modules/sqlite3/lib/sqlite3.js:190:30)
      at Object../node_modules/sqlite3/lib/sqlite3.js (/Users/raphaelsoul/Projects/electronApp/dist/main/main.js:11122:1)
      at __webpack_require__ (/Users/raphaelsoul/Projects/electronApp/dist/main/main.js:687:30)
      at fn (/Users/raphaelsoul/Projects/electronApp/dist/main/main.js:72:20)
      at eval (webpack-internal:///./src/main/core/db.ts:2:65)
      at Object../src/main/core/db.ts (/Users/raphaelsoul/Projects/electronApp/dist/main/main.js:14037:1)
      at __webpack_require__ (/Users/raphaelsoul/Projects/electronApp/dist/main/main.js:687:30)

┗ ----------------------------

My project is a start kit from electron-webpack-quick-start
sqlite3 was installed follows readme.

Yet I have compiled binary located at /Users/raphaelsoul/Projects/electronApp/node_modules/sqlite3/lib/binding/electron-v1.8-darwin-x64/node_sqlite3.node

  • electron 1.8.4
  • electron-builder 20.8.1
  • electron-rebuild 1.7.3
  • sqlite 4.0.0
  • aws-sdk 2.226.1

Any ideas?

Most helpful comment

same problem with nwjs, successful build with nw-gyp, but fails on binary.find(...

nwjs version: 0.32.4
node-sqlite3: v4.0.2

All 4 comments

also have many warnings when bundling

WARNING in ./node_modules/sqlite3/node_modules/node-pre-gyp/lib/util/versioning.js
  17:20-67 Critical dependency: the request of a dependency is an expression
   @ ./node_modules/sqlite3/node_modules/node-pre-gyp/lib/util/versioning.js
   @ ./node_modules/sqlite3/node_modules/node-pre-gyp/lib sync ^\.\/.*$
   @ ./node_modules/sqlite3/node_modules/node-pre-gyp/lib/node-pre-gyp.js
   @ ./node_modules/sqlite3/lib/sqlite3.js
   @ ./src/main/core/db.ts
   @ ./src/main/index.ts
   @ multi ./node_modules/electron-webpack/out/electron-main-hmr/main-hmr ./node_modules/electron-webpack/out/configurators/vue/vue-main-dev-entry.js ./src/main/index.ts

  WARNING in ./node_modules/sqlite3/node_modules/node-pre-gyp/lib/pre-binding.js
  20:22-48 Critical dependency: the request of a dependency is an expression
   @ ./node_modules/sqlite3/node_modules/node-pre-gyp/lib/pre-binding.js
   @ ./node_modules/sqlite3/node_modules/node-pre-gyp/lib/node-pre-gyp.js
   @ ./node_modules/sqlite3/lib/sqlite3.js
   @ ./src/main/core/db.ts
   @ ./src/main/index.ts
   @ multi ./node_modules/electron-webpack/out/electron-main-hmr/main-hmr ./node_modules/electron-webpack/out/configurators/vue/vue-main-dev-entry.js ./src/main/index.ts

  WARNING in ./node_modules/sqlite3/lib/sqlite3.js
  4:14-35 Critical dependency: the request of a dependency is an expression
   @ ./node_modules/sqlite3/lib/sqlite3.js
   @ ./src/main/core/db.ts
   @ ./src/main/index.ts
   @ multi ./node_modules/electron-webpack/out/electron-main-hmr/main-hmr ./node_modules/electron-webpack/out/configurators/vue/vue-main-dev-entry.js ./src/main/index.ts

  WARNING in ./node_modules/sqlite3/node_modules/node-pre-gyp/lib/util/compile.js
  Module not found: Error: Can't resolve 'npm' in '/Users/raphaelsoul/Projects/electronApp/node_modules/sqlite3/node_modules/node-pre-gyp/lib/util'
   @ ./node_modules/sqlite3/node_modules/node-pre-gyp/lib/util/compile.js 39:27-49
   @ ./node_modules/sqlite3/node_modules/node-pre-gyp/lib sync ^\.\/.*$
   @ ./node_modules/sqlite3/node_modules/node-pre-gyp/lib/node-pre-gyp.js
   @ ./node_modules/sqlite3/lib/sqlite3.js
   @ ./src/main/core/db.ts
   @ ./src/main/index.ts
   @ multi ./node_modules/electron-webpack/out/electron-main-hmr/main-hmr ./node_modules/electron-webpack/out/configurators/vue/vue-main-dev-entry.js ./src/main/index.ts

  WARNING in ./node_modules/sqlite3/node_modules/node-pre-gyp/lib/util/nw-pre-gyp/index.html
  Module parse failed: Unexpected token (1:0)
  You may need an appropriate loader to handle this file type.
  | <!doctype html>
  | <html>
  | <head>
   @ ./node_modules/sqlite3/node_modules/node-pre-gyp/lib sync ^\.\/.*$
   @ ./node_modules/sqlite3/node_modules/node-pre-gyp/lib/node-pre-gyp.js
   @ ./node_modules/sqlite3/lib/sqlite3.js
   @ ./src/main/core/db.ts
   @ ./src/main/index.ts
   @ multi ./node_modules/electron-webpack/out/electron-main-hmr/main-hmr ./node_modules/electron-webpack/out/configurators/vue/vue-main-dev-entry.js ./src/main/index.ts

  WARNING in ./node_modules/node-gyp/lib/Find-VS2017.cs
  Module parse failed: Unexpected token (7:6)
  You may need an appropriate loader to handle this file type.
  | // Usage:
  | // powershell -ExecutionPolicy Unrestricted -Version "2.0" -Command "&{Add-Type -Path Find-VS2017.cs; [VisualStudioConfiguration.Main]::Query()}"
  | using System;
  | using System.Text;
  | using System.Runtime.InteropServices;
   @ ./node_modules/node-gyp/lib sync ^\.\/.*$
   @ ./node_modules/node-gyp/lib/node-gyp.js
   @ ./node_modules/sqlite3/node_modules/node-pre-gyp/lib/util/compile.js
   @ ./node_modules/sqlite3/node_modules/node-pre-gyp/lib sync ^\.\/.*$
   @ ./node_modules/sqlite3/node_modules/node-pre-gyp/lib/node-pre-gyp.js
   @ ./node_modules/sqlite3/lib/sqlite3.js
   @ ./src/main/core/db.ts
   @ ./src/main/index.ts
   @ multi ./node_modules/electron-webpack/out/electron-main-hmr/main-hmr ./node_modules/electron-webpack/out/configurators/vue/vue-main-dev-entry.js ./src/main/index.ts

┗ ----------------------------

same problem with nwjs, successful build with nw-gyp, but fails on binary.find(...

nwjs version: 0.32.4
node-sqlite3: v4.0.2

same problem but i managed to solve it
If you use webpack, make sure add this line in externals:

externals: {
        sqlite3: 'commonjs2 sqlite3',
    },
Was this page helpful?
0 / 5 - 0 ratings

Related issues

royeradames picture royeradames  ·  20Comments

springmeyer picture springmeyer  ·  29Comments

sushantdhiman picture sushantdhiman  ·  20Comments

hersoncruz picture hersoncruz  ·  27Comments

milu2003 picture milu2003  ·  16Comments