ionic-typeorm-starter icon indicating copy to clipboard operation
ionic-typeorm-starter copied to clipboard

Production Build

Open MarkRabey opened this issue 5 years ago • 7 comments

First of all, thanks for the this fork. It got me running Ionic 4 with Typeorm.

However, when I build for production (ionic cordova run android --prod) I am unable to run my app. I have devices connected to DevTools and in the console I see the messages in the attached images. (App name is blurred out). StorageLocation is one of my entities, so I imagine StorageLocation_1 is trying to reference that table or something. Any help is greatly appreciated. screen shot 2019-02-19 at 3 49 53 pm

MarkRabey avatar Feb 19 '19 20:02 MarkRabey

Can you please show me sample code, or create a repo to test? I don't see any error on the production build.

coturiv avatar Feb 20 '19 08:02 coturiv

I'll get a sample repo up as soon as I can. Unfortunately I can't share this particular project.

MarkRabey avatar Feb 20 '19 14:02 MarkRabey

I made a repo showing that has error: https://github.com/MarkRabey/typeorm-errors

This was made by cloning this repo, and adding my Entities. I also removed the code inside runDemo().

MarkRabey avatar Feb 20 '19 19:02 MarkRabey

On a probably unrelated note, I get an error after just cloning the repository and building the project. screen shot 2019-02-20 at 4 14 22 pm

MarkRabey avatar Feb 20 '19 21:02 MarkRabey

And this error when not using the --prod option. screen shot 2019-02-20 at 4 19 33 pm

MarkRabey avatar Feb 20 '19 21:02 MarkRabey

Hi,

I was taking a look at this starter project and had the same

ERROR Error: Uncaught (in promise): RepositoryNotFoundError: No repository for "post" was found. Looks like this entity is not registered in current "default" connection?

as @MarkRabey in dev mode, both with an Android 9 (API level 28) emulator image and an Android 7 device, using the Ionic 5.4.4 and Cordova 9.0.0 as global CLI tools.

After some digging, it seems that such issues happen with TypeORM when trying to invoke getRepository('post') when the underlying database adapter isn't ready.

I found that by debugging with halt on All + Uncaught Exceptions, a "Cannot read property 'openDatabase' of undefined" happened before this error, which is often related to the platform.ready() event.

I tried a few things and found a simple working solution. I'm submitting it to you in Pull Request #5 / commit https://github.com/coturiv/ionic4-typeorm-starter/pull/5/commits/f7c0778f20d43531c5630e32a80fc57b8d5915ed.

The submitted solution both worked in dev and prod mode on my emulator and real device.

StephaneSeyvoz avatar Oct 16 '19 17:10 StephaneSeyvoz

Hi @coturiv Any update about the above issue?

Sampath-Lokuge avatar Feb 06 '20 17:02 Sampath-Lokuge