koa+typeorm dev运行正常但是 build后报错 RepositoryNotFoundError: No repository for “User” was found. Looks like this entity is not registered in current “default” connection?
如果用ormconfig.json进行orm配置的话 需要看一下entitys的目录是否正确。
如果实体类是放在/src/entity/目录下,dev运行可以找到这个实体类,但是build后entity在根目录 所以需要再加一个entity/* 这样 如下
{
"type": "mysql",
"host": "192.168.1.105",
"port": 3306,
"username": "root",
"password": "123123",
"database": "xxxx",
"synchronize": true,
"entities": ["src/entity/*.{js,ts}","entity/*.{js,ts}"], // 注意这里 加了两个 左边是dev的目录 右边是build的目录
"autoLoadEntities": true,
"cli": {
"entitiesDir": "src/entity"
},
"entityPrefix": "tp_"
}