简体   繁体   中英

Runtime error using JoinTableOptions on @ManyToMany

Having trouble trying to define a custom JoinTable on a ManyToMany relation in TypeORM.

Environment:

  • Node 16.13.0
  • TS 4.7.4
  • TypeORM 0.3.10
  @ManyToMany(() => Series)
  @JoinTable({
    name: 'tv_group_series',
    inverseJoinColumn: {
      referencedColumnName: 'id',
      name: 'tv_group_id'
    },
    joinColumn: {
      referencedColumnName: 'id',
      name: 'series_id'
    }
  })
  shows: Series[];

Without the @JoinTable options provided above, the app runs, but when I add it I get the following error at runtime:

Uncaught M:\Code\MediaMogul\MediaMogulTwo\node_modules\typeorm\browser\index.js:3
compileFunction         vm:352
wrapSafe                loader:1031
Module._compile         loader:1065
Module._extensions..js  loader:1153
Module.load             loader:981
Module._load            loader:822
Module.require          loader:1005
require                 helpers:102
(anonymous function)    Group.ts:3
Module._compile         loader:1101
Module._extensions..js  loader:1153
Module.load             loader:981
Module._load            loader:822
Module.require          loader:1005
require                 helpers:102
(anonymous function)    TypeORMManager.ts:22
Module._compile         loader:1101
Module._extensions..js  loader:1153
Module.load             loader:981
Module._load            loader:822
Module.require          loader:1005
require                 helpers:102
(anonymous function)    www.ts:4
Module._compile         loader:1101
Module._extensions..js  loader:1153
Module.load             loader:981
Module._load            loader:822
executeUserEntryPoint   run_main:81
(anonymous function)    run_main_module:17

The "TypeORMManager.ts:22" line is just the import statement for the class. I wish there was a more descriptive error at the very least, and would love advice on how to get one. Clearly there's something gone wrong with the reflection on those decorators, but I can't debug what. It looks a lot like the working examples I've seen online.

Elsewhere in my code, I have working @Columns, @OneToMany, @ManyToOne relations, all with custom options as well.

Does anyone have any suggestions on how to debug this?

Thanks!

Nevermind. It turns out WebStorm auto-imported JoinTable from 'typeorm/browser' instead of 'typeorm'. Changed that, and it runs without issue.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM