question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

sqlite3 packaging error - Cannot find module

See original GitHub issue

I am trying to bundle sqlite3 into my program, which was installed in the usual way using npm install sqlite3.

I run the following command to package, which runs without errors or warnings.:

chris@chris-server:~/Storage/Programming/tempoServer$ pkg package.json && mv tempo-server-* ./dist/
> pkg@4.4.0
> Targets not specified. Assuming:
  node8-linux-x64, node8-macos-x64, node8-win-x64

After distributing the executable to another machine and executing it, I get the following output:

chris@chris-remote:~/Storage/tempoServer$ ./tempo-server-linux
pkg/prelude/bootstrap.js:1185
      throw error;
      ^

Error: Cannot find module '/snapshot/tempoServer/node_modules/sqlite3/lib/binding/node-v57-linux-x64/node_sqlite3.node'
1) If you want to compile the package/file into executable, please pay attention to compilation warnings and specify a literal in 'require' call. 2) If you don't want to compile the package/file into executable and want to 'require' it from filesystem (likely plugin), specify an absolute path in 'require' call using process.cwd() or process.execPath.
    at Function.Module._resolveFilename (module.js:546:15)
    at Function.Module._resolveFilename (pkg/prelude/bootstrap.js:1287:46)
    at Function.Module._load (module.js:473:25)
    at Module.require (module.js:595:17)
    at Module.require (pkg/prelude/bootstrap.js:1166:31)
    at require (internal/module.js:11:18)
    at Object.<anonymous> (/snapshot/tempoServer/node_modules/sqlite3/lib/sqlite3.js:4:15)
    at Module._compile (pkg/prelude/bootstrap.js:1261:22)
    at Object.Module._extensions..js (module.js:662:10)
    at Module.load (module.js:564:32)

The dependincy is included using const sqlite = require('sqlite3');, and works perfectly when starting the program through NPM.

Any suggestions? I have tried including the entire node_modules folder in my package.json pkg config, as well as just including the sqlite3 folder, both with the same error. Running pkg through pkg server.js also has the same results.

Issue Analytics

  • State:closed
  • Created 4 years ago
  • Reactions:3
  • Comments:6

github_iconTop GitHub Comments

2reactions
sharathbaddamcommented, Jul 29, 2019

@FabianTe i have a gulp script as following that replaces the code in sqlite3.js file before building an exe

function sqlite(done) { gulp.src(['node_modules/sqlite3/lib/sqlite3.js']) .pipe(replace("require(binding_path)", "require('./node_sqlite3.node)")) .pipe(gulp.dest('node_modules/sqlite3/lib/')) .once("error", function () { this.once("finish", () => process.exit(1));}) .once("end", function() { done()}); }

0reactions
robertsLandocommented, Apr 2, 2021

This should be fixed here: https://github.com/vercel/pkg/blob/master/dictionary/sqlite3.js also now .node files should automatically be added to the executable, if not you just have to specify them in assets

Read more comments on GitHub >

github_iconTop Results From Across the Web

sqlite3 packaging error - Cannot find module · Issue #690
I am trying to bundle sqlite3 into my program, which was installed in the usual way using npm install sqlite3. I run the...
Read more >
electron-packager and sqlite3 - Cannot find module when .exe ...
I am trying to build a simple electron app that uses sqlite3. I want to create an .exe with the help of electron-packager....
Read more >
[ERROR] Cannot find module 'sqlite3' in SAP CAP model in ...
While I was trying to deploy an application onto the in-memory db sqlite, I get the following error: [ERROR] Cannot find module 'sqlite3'....
Read more >
better-sqlite3 - npm
The fastest and simplest library for SQLite3 in Node.js. Full transaction support; High performance, efficiency, and safety; Easy-to-use ...
Read more >
Cannot find module '@vscode/sqlite3' - Ghost Forum
Message: Ghost was able to start, but errored during boot with: Knex: run $ npm install sqlite3 --save Cannot find module '@vscode/sqlite3' ...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found