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.

Question: Electron + TypeORM + Webpack UglifyJsPlugin

See original GitHub issue

Issue type:

[X] question [ ] bug report [ ] feature request [ ] documentation issue

Database system/driver:

[ ] cordova [ ] mongodb [ ] mssql [ ] mysql / mariadb [ ] oracle [ ] postgres [X] sqlite [ ] sqljs [ ] react-native

TypeORM version:

[X] latest [ ] @next [ ] 0.x.x (or put your version here)

I’m setting up my connection like this:

 import { Table1 } from '../../entity/table1';
 import { Table2 } from '../../entity/table2';
 import { Table2 } from '../../entity/table3';

 const dbpath = require('os').homedir() + '/.myapp/db.sqlite'

 createConnection({
            type: 'sqlite',
            database: dbpath,
            entities: [
                Table1,
                Table2,
                Table3
            ]
        }).then(connection => {
            console.log('connected to sql from typeorm')
        }).catch(error => console.log(error));

This works just fine in dev, but in prod, it fails to find the tables.

QueryFailedError: SQLITE_ERROR: no such table: e

I suspect its because in prod, webpack runs UglifyJsPlugin. Doe’s anyone know how to fix this?

Issue Analytics

  • State:closed
  • Created 5 years ago
  • Reactions:1
  • Comments:10 (5 by maintainers)

github_iconTop GitHub Comments

9reactions
gregbarczacommented, Dec 4, 2018

Quick fix:

// webpack.config.js
module.exports = {
...
optimization: {
    minimize: false
  }
...
8reactions
pleerockcommented, May 9, 2018

you need to put table name into entity like this: @Entity("table1") export class Table1 {

Read more comments on GitHub >

github_iconTop Results From Across the Web

Electron application SQLITE package has not been found ...
SQLite3 is a native Node.js module so it can't be used directly with Electron without rebuilding it to target Electron.The electron-builder ...
Read more >
How to Use TypeORM with Webpack - Atomic Spin
This happens because TypeORM is running inside the Webpack build and trying to require the un-compiled code that is specified in the entities...
Read more >
typeorm error driver not connected - You.com | The AI Search ...
I suspect its because in prod, webpack runs UglifyJsPlugin. Doe's anyone know how to fix this? Open side panel.
Read more >
sql.js - Bountysource
After I import the sql.js on my electron-react project, I got following ... result.request.replace(/typeorm/, "typeorm/browser"); }), new Webpack.
Read more >
[Solved]-Webpack - SyntaxError: Unexpected token {-node.js
Coding example for the question Webpack - SyntaxError: Unexpected token {-node.js.
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