TypeORM 0.2.21:无法读取未定义的属性“ build”

时间:2019-12-11 12:40:48

标签: typescript typeorm

我不确定每次尝试与数据库同步时为什么会出现以下错误。

Error during schema synchronization:
TypeError: Cannot read property 'build' of undefined
    at /Users/geekox86/Documents/GitHub/OE Scoring/src/metadata-builder/EntityMetadataBuilder.ts:594:66
    at Array.forEach (<anonymous>)
    at EntityMetadataBuilder.computeEntityMetadataStep2 (/Users/geekox86/Documents/GitHub/OE Scoring/src/metadata-builder/EntityMetadataBuilder.ts:594:37)
    at /Users/geekox86/Documents/GitHub/OE Scoring/src/metadata-builder/EntityMetadataBuilder.ts:113:56
    at Array.forEach (<anonymous>)
    at EntityMetadataBuilder.build (/Users/geekox86/Documents/GitHub/OE Scoring/src/metadata-builder/EntityMetadataBuilder.ts:113:25)
    at ConnectionMetadataBuilder.buildEntityMetadatas (/Users/geekox86/Documents/GitHub/OE Scoring/src/connection/ConnectionMetadataBuilder.ts:66:111)
    at Connection.buildMetadatas (/Users/geekox86/Documents/GitHub/OE Scoring/src/connection/Connection.ts:516:59)
    at Connection.<anonymous> (/Users/geekox86/Documents/GitHub/OE Scoring/src/connection/Connection.ts:191:18)
    at step (/Users/geekox86/Documents/GitHub/OE Scoring/node_modules/tslib/tslib.js:136:27)

Reproduction repo

1 个答案:

答案 0 :(得分:0)

typeorm尝试调用的方法是build typeorm/src/metadata-builder/EntityMetadataBuilder.ts并具有下一个签名:

build(entityClasses?: Function[]): EntityMetadata[]) {}

它的作用是为给定的实体类构建完整的实体元数据,并为表继承计算父实体元数据。

告诉我的是,您尝试创建实体之间的关系的方式存在问题。您可能需要通过暂时删除关系来逐一检查关系,直到找到造成问题的关系。