I'm trying to add an Idea entity to my TypeOrm (configured to mysql), and it seems like the imports refuse to work. With the file added, the typeorm doesn't initialize successfully.
I've reinstalled typeorm package, and I have no idea where to start debugging. I'm following a tutorial ( https://www.youtube.com/watch?v=EHlhvy-fh90), in which this error does NOT appear. I've deviated from it by replacing a postgresql database with a dockerized mysql.
I've had some trouble setting up the node -> mysql connection, eventually opting to run a dockerized mysql 5 to account for auth errors (following this answer: https://stackoverflow.com/a/50167617/9043642). Without the idea.entity.ts file, the connection goes through (with orm), so I wouldn't expect there to be a problem with the database.
This is what my idea.entity.ts file looks like. It effectively follows the example found in documentation (https://docs.nestjs.com/techniques/database). Copy and pasted, the documentation example gives the same error anyway.
import {
Entity,
PrimaryGeneratedColumn,
Column,
CreateDateColumn,
} from 'typeorm';
@Entity()
export class IdeaEntity {
@PrimaryGeneratedColumn('uuid') id:string;
@CreateDateColumn() created:Date;
@Column('text') idea:string;
@Column('text') description:string;
}
I'm getting the following error while running
[Nest] 14034 - 07/02/2019, 1:00 PM [TypeOrmModule] Unable to connect to the database. Retrying (1)... +19ms
[0] /home/miko/node/ideas/src/idea/idea.entity.ts:2
[0] import { Entity, Column, PrimaryGeneratedColumn } from 'typeorm';
[0] ^
[0]
[0] SyntaxError: Unexpected token {
[0] at Module._compile (internal/modules/cjs/loader.js:718:23)
[0] at Object.Module._extensions..js (internal/modules/cjs/loader.js:785:10)
[0] at Module.load (internal/modules/cjs/loader.js:641:32)
[0] at Function.Module._load (internal/modules/cjs/loader.js:556:12)
[0] at Module.require (internal/modules/cjs/loader.js:681:19)
[0] at require (internal/modules/cjs/helpers.js:16:16)
[0] at Function.PlatformTools.load (/home/miko/node/ideas/node_modules/typeorm/platform/PlatformTools.js:107:28)
[0] at /home/miko/node/ideas/node_modules/typeorm/util/DirectoryExportedClassesLoader.js:30:69
[0] at Array.map (<anonymous>)
[0] at Object.importClassesFromDirectories (/home/miko/node/ideas/node_modules/typeorm/util/DirectoryExportedClassesLoader.js:30:10)
Notably, the database connection flops. Again, without the idea entity present the connection is fine. The expected result is [InstanceLoader] TypeOrmCoreModule dependencies initialized
. How would I successfully create an entity like this?