Pkg: I got the error Please install sqlite3 package manually

Created on 18 Oct 2017  路  9Comments  路  Source: vercel/pkg

Hi guys, I need help I'm novice in this... When I try to run my .exe or for macos result I got the same error, it is like sqlite3 it's not including in the compression, also I see another issue closed but with not answer of it.

pkg/prelude/bootstrap.js:1155
throw error;
^
Error: Please install sqlite3 package manually

if you need more information let me know, I'm really excited for using this awesome package.

Most helpful comment

You have to include the precompiled sqlite3 extension. You'll find it in node_modules/sqlite3/lib/binding/xxx/node_sqlite3.node

xxx being a node version + platform.

Copy that .node file in the same directory as your generated executable and it should work fine.

If anyone knows how to incorporate it in executables generated by pkg, that'd be nice

All 9 comments

You have to include the precompiled sqlite3 extension. You'll find it in node_modules/sqlite3/lib/binding/xxx/node_sqlite3.node

xxx being a node version + platform.

Copy that .node file in the same directory as your generated executable and it should work fine.

If anyone knows how to incorporate it in executables generated by pkg, that'd be nice

Thanks @AxelTerizaki for your answer, yes I think that help me but now I'm getting this error:
pkg/prelude/bootstrap.js:1155 throw error; ^
TypeError: Cannot read property 'afterUpdate' of undefined at /snapshot/inventory-tool/backend/commands.js:52:9 at Object.<anonymous> (/snapshot/inventory-tool/backend/commands.js:2935:2) at Module._compile (pkg/prelude/bootstrap.js:1226:22) at Object.Module._extensions..js (module.js:579:10) at Module.load (module.js:487:32) at tryModuleLoad (module.js:446:12) at Function.Module._load (module.js:438:3) at Module.require (module.js:497:17) at Module.require (pkg/prelude/bootstrap.js:1136:31) at require (internal/module.js:20:19) at /snapshot/inventory-tool/server.js:15:15 at Object.<anonymous> (/snapshot/inventory-tool/server.js:101:2) at Module._compile (pkg/prelude/bootstrap.js:1226:22) at Object.Module._extensions..js (module.js:579:10) at Module.load (module.js:487:32) at tryModuleLoad (module.js:446:12)

I'm using Sequelize to handle my sqlite, and look like my hooks/trigger are no declare in the node_sqlite3.node for some reasons, maybe the problem is that sequelize has sqlte3 as dependency and put the node_sqlit3.node outside of the compression of the executeable generate this error.

example of one hook:
const Article = require('./models').articles;

Article.afterUpdate(function (instance, options, fn){ // code exec each time after update the article model.... });

To see if I get more problems after fix that, I commeted all the hooks/triggers I have afterUpdate/afterCreate by example and when I run that it not show me error, but then when I go to the broswer and try to navegate always appear "Cannot GET /" in the blank page. My server file is using express

const app = express(); ... app.use(express.static(__dirname + '/frontend'));

then in my frontend I'm using angular router to navigate

Thanks so much for helping me, looks like a complicated situation but thanks for the efforts!

I can't answer your specific problem but I could dierct you to my current project, which is using pkg.

It's an app which also serves files, so you have to be careful of how you do setup your package.json so pkg knows exactly where to put what. It uses sqlite3 as well.

See here to check how we configured pkg, maybe that'll help you :
https://lab.shelter.moe/karaokemugen/karaokemugen-app/blob/master/package.json

Thanks you, that really help me, the solution was correct my pkg section (js and importants assets) inside of package.json and put the node_sqlite3.node in the same directory, also I had to put my_database.sqlite in the same directory of the .node file

By the way if you wanna make exec for x84 and x64 you always need find the precompiled sqlite3 extension, that's mean you always need to get the precompiled sqlite3 from others computers/os with different arch (x84,x64) because if you put the wrong arch you will get erros

Thanks a lot man !!

I've placed node_sqlite3.node in the same directory as my pkg'd app yet I continue to get the error

Error: Cannot find module '/snapshot/a-dream-deferred/node_modules/sqlite3/lib/binding/node-v64-darwin-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.

every time I run my packaged app. Is there a step to the process I'm missing?

@unitof The sqlite3 module still wants to load the .node file from the snapshot file sytem. That's because pkg saw the require call (somewhere in the sqlite3 internals) and converted it to a snapshot require.

In #690 @sharathbaddam stated that he somehow changed this so that it tries loads it from some other path. I already asked there how he did that.

Update: Having the .node file in the same dir as the executable (and process workdir) does the trick

@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()});
}

Ah, thanks! Strangely I can use it just as is, have you checked that your workarround is needed anymore? 馃槈

Anyway, I might use this since I'd like to have the .node file in a lib folder or similar.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

serzhiio picture serzhiio  路  3Comments

peterjwest picture peterjwest  路  3Comments

asaf050 picture asaf050  路  3Comments

Nisthar picture Nisthar  路  4Comments

ydubois-fr picture ydubois-fr  路  4Comments