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 #25

Open
hwooo opened this issue Jan 6, 2023 · 1 comment
Open

SyntaxError: Cannot use import statement outside a module #25

hwooo opened this issue Jan 6, 2023 · 1 comment

Comments

@hwooo
Copy link

hwooo commented Jan 6, 2023

/var/app/current/node_modules/typeorm-transactional/tests/entities/Post.entity.ts:1
"import { Entity, PrimaryGeneratedColumn, Column } from 'typeorm';
 ^^^^^^

SyntaxError: Cannot use import statement outside a module
  • app.module.ts
import ormconfig from '../ormconfig';

@Module({
  imports: [
    ConfigModule.forRoot({
      isGlobal: true,
      cache: true,
    }),
    TypeOrmModule.forRootAsync({
      useFactory: () => ormconfig,
      dataSourceFactory: async (options) => {
        const dataSource = await addTransactionalDataSource({
          dataSource: new DataSource(options),
          patch: true,
        })
        return dataSource;
      },
    }),
    ...
  ],
  controllers: [...],
  providers: [...],
})
export class AppModule implements NestModule {
  ...
}

If I run NestJS application on AWS Elastic Beanstalk, TypeError is occurred after deploy.
There is no issue in my local environment. It only occurs in ELB.
However environment variables are completely same, and Node 14.x and 16.x both have same problem.

  • ormconfig.ts
const ormconfig: TypeOrmModuleOptions = {
  type: 'mysql',
  host: process.env.DATABASE_MASTER_HOST,
  ...
  synchronize: true,
  migrationsRun: true,
  logging: true,
  keepConnectionAlive: true,
  namingStrategy: new SnakeNamingStrategy(),
  entities: [__dirname + '/**/*.entity.{js,ts}'],
  subscribers: ['src/subscriber/**/*.ts'],
  migrations: [__dirname + '/database/migrations/**/*.ts'],
  migrationsTableName: 'migrations',
}
export default ormconfig;
@Serg890
Copy link

Serg890 commented Feb 27, 2023

@hwooo Did you solve the problem?

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