I'm trying to setup migrations config in my nestjs app with typeorm. Currently I'm getting error when trying to start app by running the script yarn start:dev.
import { DataSource } from 'typeorm'; ^^^^^^ SyntaxError: Cannot use import statement outside a module
My DataSource config looks like:
import * as dotenv from 'dotenv';
dotenv.config();
const config = new DataSource({
type: 'postgres',
host: process.env.POSTGRES_HOST,
port: Number(process.env.POSTGRES_PORT),
username: process.env.POSTGRES_USER,
password: process.env.POSTGRES_PASSWORD,
database: process.env.POSTGRES_DB,
migrations: [__dirname + '/../*.js', __dirname + '/../**/*.js'],
migrationsTableName: 'migration',
});
export default config;```
And the path in my app to this file is src/migration/config/ormConfig.ts. Also in src/migration I got all my migrations and some of them inside folders - src/migration/someFolder/someMigration.js and so on. Why am I getting such error? And how can I run my app without this error? In my package.json - "ts-node": "^10.9.1", "typeorm": "^0.3.17", "typescript": "^5.2.2"