Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

SyntaxError: Cannot use import statement outside a module #32

Open
Serg890 opened this issue Feb 27, 2023 · 1 comment
Open

SyntaxError: Cannot use import statement outside a module #32

Serg890 opened this issue Feb 27, 2023 · 1 comment

Comments

@Serg890
Copy link

Serg890 commented Feb 27, 2023

The project starts and works, but when I run the migration I get the following error.

Also, I tried deleting the Post.entity.ts file from node modules and it works correctly but it's not quite correct to change.

How can I fix it?

**\node_modules\typeorm-transactional\tests\entities\Post.entity.ts:1

"import { Entity, PrimaryGeneratedColumn, Column } from 'typeorm';
^^^^^^

SyntaxError: Cannot use import statement outside a module

  • ormconfig.ts
export const dataSource = new DataSource({
  logging: false,
  type: "postgres",
  host: process.env.TYPEORM_HOST,
  port: parseInt(process.env.TYPEORM_PORT),
  username: process.env.TYPEORM_USERNAME,
  password: process.env.TYPEORM_PASSWORD,
  database: process.env.TYPEORM_DATABASE,
  synchronize: false,
  entities: [join(__dirname, '**', '*.entity.{ts,js}')],
  migrations: [join(__dirname, "src", "migrations", "*.ts")],
  migrationsRun: true,
});

@msanandrea
Copy link

@Serg890 same to me. Deleted the tests folder and worked. Any definitive solution for this?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants