TypeError: someClass is not a constructor
See original GitHub issueIssue type:
[ ] question [x] bug report [ ] feature request [x] documentation issue
Database system/driver:
[ ] cordova
[ ] mongodb
[ ] mssql
[ ] mysql / mariadb
[ ] oracle
[x] postgres
[ ] cockroachdb
[ ] sqlite
[ ] sqljs
[ ] react-native
[ ] expo
TypeORM version:
[x] latest
[ ] @next
[ ] 0.x.x (or put your version here)
Steps to reproduce or a small repository showing the problem:
I have been trying for hours to generate a migration, but seems that everything is leading to a typeorm error
this is my Entity
import { Entity, PrimaryGeneratedColumn, Column, CreateDateColumn, UpdateDateColumn } from "typeorm";
@Entity()
export class CommentEntity {
@PrimaryGeneratedColumn()
id!: number;
@CreateDateColumn()
createdAt!: Date;
@UpdateDateColumn()
updatedAt!: Date;
@Column()
userNickname!: string;
@Column()
content!: string;
}
this is my ormconfig.json
{
"type": "postgres",
"host": "localhost",
"port": 5432,
"username": "postgres",
"password": "",
"database": "postgres",
"logging": false,
"entities": [
"modules/comments/CommentEntity.ts"
],
"migrations": [
"migrations/*.ts"
],
"cli": {
"migrationsDir": "migrations"
}
}
and then I run
./node_modules/.bin/ts-node ./node_modules/typeorm/cli.js migration:generate -n Comment
this is the output of the script
TypeError: someClass is not a constructor
at class_1.get (/home/user/Development/myapp/src/src/container.ts:34:51)
at Object.getFromContainer (/home/user/Development/myapp/src/src/container.ts:71:29)
at /home/user/Development/myapp/src/src/connection/ConnectionMetadataBuilder.ts:35:58
at Array.map (<anonymous>)
at ConnectionMetadataBuilder.buildMigrations
(/home/user/Development/myapp/src/src/connection/ConnectionMetadataBuilder.ts:35:36)
at Connection.buildMetadatas (/home/user/Development/myapp/src/src/connection/Connection.ts:520:54)
at Connection.<anonymous> (/home/user/Development/myapp/src/src/connection/Connection.ts:191:18)
at step (/home/user/Development/myapp/src/node_modules/tslib/tslib.js:136:27)
at Object.next (/home/user/Development/myapp/src/node_modules/tslib/tslib.js:117:57)
at fulfilled (/home/user/Development/myapp/src/node_modules/tslib/tslib.js:107:62)
I have tried for a full text search on my IDE for someClass because it looks like some kind of placeholder for testing that someone forgot in the code, but there was nothing.
Thanks
Issue Analytics
- State:
- Created 4 years ago
- Reactions:8
- Comments:13 (1 by maintainers)
Top Related StackOverflow Question
I KNEW I had seen that before. Take a look at my previous issue: https://github.com/typeorm/typeorm/issues/5079
You have a file inside your migrations dir that isn’t a TS file or doesn’t match your migration file glob pattern
This is the correct way to initialize migrations and entities:- (https://github.com/nrwl/nx/issues/803)