-
-
Notifications
You must be signed in to change notification settings - Fork 6.5k
Closed
Description
Issue type:
[ ] question
[ x ] bug report
[ ] feature request
[ ] documentation issue
Database system/driver:
[ ] cordova
[ ] mongodb
[ ] mssql
[ x ] mysql / mariadb
[ ] oracle
[ x ] postgres
[ x ] sqlite
[ ] sqljs
[ ] websql
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 the following orm configuration json file:
{
"type": "mysql",
"host": "localhost",
"port": 13306,
"username": "root",
"password": "acclink",
"database": "ts_test",
"synchronize": true,
"logging": false,
"entities": [
"src/entity/**/*.ts"
],
"migrations": [
"src/migrations/**/*.ts"
],
"subscribers": [
"src/subscriber/**/*.ts"
],
"cli": {
"entitiesDir": "src/entity",
"migrationsDir": "src/migrations",
"subscribersDir": "src/subscriber"
}
}I have this User entity class:
import {Entity, PrimaryGeneratedColumn, Column, CreateDateColumn, UpdateDateColumn, ManyToOne} from "typeorm";
@Entity()
export class User {
@PrimaryGeneratedColumn()
id: number;
@Column({
type: "varchar",
length: 150,
unique: true
})
uuid: string;
@Column({
type: "varchar",
length: 180,
unique: true
})
email: string;
@Column({
type: "varchar",
length: 20,
unique: true
})
username: string;
@Column({
type: "varchar",
length: 150
})
password: string;
@Column({
type: "varchar",
length: 150
})
salt: string;
@Column({
type: "varchar",
length: 150
})
displayName: string;
@Column({
type: "varchar",
length: 150
})
activationCode: string;
@Column({type: "json"})
role: string;
@CreateDateColumn()
createdAt: Date;
@ManyToOne(type => User)
userCreator: User;
@UpdateDateColumn()
updatedAt: Date;
@ManyToOne(type => User)
userUpdater: User;
@Column({type: "boolean"})
isActive: boolean;
}And my UserRepository class is the following:
import {EntityRepository, Repository} from "typeorm";
import {User} from "../User";
@EntityRepository(User)
export class UserRepository extends Repository<User> {
public findByName(displayName: string) {
return this.findOne({ displayName });
}
}If I execute the command to generate a migration, it gives me the following error:
$ typeorm migrations:generate -n
Error during migration generation:
/var/www/javascript/api-coins/src/entity/repository/UserRepository.ts:1
(function (exports, require, module, __filename, __dirname) { import {EntityRepository, Repository} from "typeorm";
^^^^^^
SyntaxError: Unexpected token import
at createScript (vm.js:80:10)
at Object.runInThisContext (vm.js:139:10)
at Module._compile (module.js:607:28)
at Object.Module._extensions..js (module.js:654:10)
at Module.load (module.js:556:32)
at tryModuleLoad (module.js:499:12)
at Function.Module._load (module.js:491:3)
at Module.require (module.js:587:17)
at require (internal/module.js:11:18)
at Function.PlatformTools.load (/opt/node/lib/node_modules/typeorm/platform/PlatformTools.js:124:28)
I've removed the content of my UserRepository class, I receive the following error:
$ typeorm migrations:generate -n
Error during migration generation:
/var/www/javascript/api-coins/src/entity/repository/UserRepository.ts:1
(function (exports, require, module, __filename, __dirname) { import {EntityRepository, Repository} from "typeorm";
^^^^^^
SyntaxError: Unexpected token import
at createScript (vm.js:80:10)
at Object.runInThisContext (vm.js:139:10)
at Module._compile (module.js:607:28)
at Object.Module._extensions..js (module.js:654:10)
at Module.load (module.js:556:32)
at tryModuleLoad (module.js:499:12)
at Function.Module._load (module.js:491:3)
at Module.require (module.js:587:17)
at require (internal/module.js:11:18)
at Function.PlatformTools.load (/opt/node/lib/node_modules/typeorm/platform/PlatformTools.js:124:28)Notes: That's my first migration and my database was created but it's empty
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
No labels