首页 > 解决方案 > TypeORM ColumnTypeUndefined 错误排查步骤?

问题描述

将 TypeORM 添加到 vanilla Javascript 项目但收到此错误。该项目使用 webpack 打包,由弹出的 create-react-app 构建。

ColumnTypeUndefinedError: Column type for Commodity#name is not defined and
cannot be guessed. Make sure you have turned on an "emitDecoratorMetadata": true
option in tsconfig.json. Also make sure you have imported "reflect-metadata on
top of the main entry file in your application (before any entity imported). If
you are using JavaScript instead of TypeScript you must explicitly provide a
column type.

按照说明进行操作。看到反射是在全局范围内。仍然收到错误。从这里推荐哪些步骤?

标签: typescriptwebpacktypeorm

解决方案


@Column() 必须设置一个类型,例如 @Column('text',{nullable:true})。

更多信息在https://github.com/typeorm/typeorm/issues/2897


推荐阅读