Communities for your favorite technologies. Explore all Collectives
Stack Overflow for Teams is now called Stack Internal. Bring the best of human thought and AI automation together at your work.
Bring the best of human thought and AI automation together at your work. Learn more
Find centralized, trusted content and collaborate around the technologies you use most.
Stack Internal
Knowledge at work
Bring the best of human thought and AI automation together at your work.
When executing the command npm run start: dev with migrations configured I receive the error import {MigrationInterface, QueryRunner} from "typeorm"; SyntaxError: Cannot use import statement outside a module
npm run start: dev
const config: ConnectionOptions = { type: 'mysql', host: process.env.DATABASE_HOST, port: parseInt(process.env.DATABASE_PORT), username: process.env.DATABASE_USER, password: process.env.DATABASE_PASSWORD, database: process.env.DATABASE_NAME, entities: [__dirname + '/**/*.entity{.ts,.js}'], synchronize: false, logging: true, migrationsRun: true, migrations: [__dirname + '/../migrations/**/*{.ts,.js}'], cli: { migrationsDir: './migrations', } } export = config;
ConfigModule.forRoot(), TypeOrmModule.forRoot({...ormconfig, keepConnectionAlive: true, autoLoadEntities: true}),
"typeorm": "ts-node -r tsconfig-paths/register ./node_modules/typeorm/cli.js --config ./src/ormconfig.ts", "migration:generate": "npm run typeorm migration:generate -- -n", "migration:run": "npm run typeorm migration:run", "migration:revert": "npm run typeorm migration:revert"
I fix it by moving the migrations folder inside src.
Add a comment
Required, but never shown
By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.
Start asking to get answers
Find the answer to your question by asking.
Explore related questions
See similar questions with these tags.
const config: ConnectionOptions = { type: 'mysql', host: process.env.DATABASE_HOST, port: parseInt(process.env.DATABASE_PORT), username: process.env.DATABASE_USER, password: process.env.DATABASE_PASSWORD, database: process.env.DATABASE_NAME, entities: [__dirname + '/**/*.entity{.ts,.js}'], synchronize: false, logging: true, migrationsRun: true, migrations: [__dirname + '/../migrations/**/*{.ts,.js}'], cli: { migrationsDir: './migrations', } } export = config;ConfigModule.forRoot(), TypeOrmModule.forRoot({...ormconfig, keepConnectionAlive: true, autoLoadEntities: true}),"typeorm": "ts-node -r tsconfig-paths/register ./node_modules/typeorm/cli.js --config ./src/ormconfig.ts", "migration:generate": "npm run typeorm migration:generate -- -n", "migration:run": "npm run typeorm migration:run", "migration:revert": "npm run typeorm migration:revert"npm run start: devworks fine.