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.

Sqlite driver in Webpack/Electron on 0.2.28: (TypeError): this.driver.connect is not a function

See original GitHub issue

Issue type:

[x] bug report [ ] feature request [ ] documentation issue

Database system/driver:

[ ] cordova [ ] mongodb [ ] mssql [ ] mysql / mariadb [ ] oracle [ ] postgres [ ] cockroachdb [x] sqlite [ ] sqljs [ ] react-native [ ] expo

TypeORM version:

0.2.28

Steps to reproduce or a small repository showing the problem:

Clone the reproduction repo at https://github.com/jjhbw/typeorm-webpack-electron-repro See simple instructions on how to trigger the error in the repo’s README. Note that the invocation of createConnection resides in src/App.js.

Issue Analytics

  • State:closed
  • Created 3 years ago
  • Comments:16 (15 by maintainers)

github_iconTop GitHub Comments

8reactions
henrique3gcommented, Oct 23, 2020

@dominicdesu @jjhbw First sorry for my english kk, i am creating an application using vue and electron and encountered the same problem, i solved this with folow config in webpack

module.exports = {
  // ...
  externals: {
    typeorm: 'commonjs typeorm',
    sqlite3: 'commonjs sqlite3'
  }
};

My solution was this and electron builder config, for you this solution should solve. The original webpack documentation: https://webpack.js.org/configuration/externals/#externals The issue where encountered the solution for my problem: https://github.com/nklayman/vue-cli-plugin-electron-builder/issues/699

1reaction
jjhbwcommented, Oct 5, 2020

The sqlite driver uses https://www.npmjs.com/package/sqlite which is a binary driver that is only available for node. It does not work from a browser as it’s a C library.

Yes, i’m aware. Hence my snark regarding the hypothetical devs who try to use it in a browser context. 😉

If we do not do this then webpack build targeting browsers with mainFields will fail to build entirely, as webpack tries to resolve this even if the file is not imported.

Ah, that makes sense. Did not think of that case. In light of that, I’d say you’re right not to accommodate this in TypeORM… I guess the only way is to get Webpack to fix the mainFields issue instead.

Thanks for the time you spend on this library! Much appreciated.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Typeorm not working in my electron app (this.driver connect is ...
It seems like an Issue of me being in browser not having direct access to node.js sqlite driver, but according to typeorm docs...
Read more >
typeorm error driver not connected - You.com | The AI Search ...
I tried to use typeorm for aws lambda functions. A first query to database worked. But after first query(after connection established), all queries...
Read more >
typeorm: CHANGELOG
we do not call JSON.stringify() to json/jsonb column types in Postgres. Instead, we delegate value directly to underlying pg driver.
Read more >
sqlite3 - Go Packages
Package sqlite3 provides interface to SQLite3 databases. This works as a driver for database/sql. Installation go get github.com/mattn/go- ...
Read more >
Connect To The SQLite Database Using SQLite JDBC Driver
In this tutorial, we will show you how to download SQLite JDBC Driver and connect to the SQLite database via JDBC, source code...
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