Closed tipoc123 closed 10 months ago
I even simplified the migration file to a single console.log
call (for testing purposes):
This looks like SWC issue in relation to distro, my automated tests are running on ubuntu-latest
Which distro is used in your docker container?
FROM node:18.12.1
Is this information enough?
Made an example it's working with your node:18.12.1
Check https://github.com/ilovepixelart/ts-express-swc/commit/7ce8578701139fdd255d1e175cfdd948e2aa5a52
Any other ideas what could be the problem?
Same example with nets all works, I think it's your setup closing this issue https://github.com/ilovepixelart/ts-express-nest
I wrapped the import in try-catch and this is the error in the logs:
/opt/nest-api/migrations/1699935100948-drop-orders.ts:1
import * as mongoose from 'mongoose';
^^^^^^
SyntaxError: Cannot use import statement outside a module
at Object.compileFunction (node:vm:360:18)
at wrapSafe (node:internal/modules/cjs/loader:1088:15)
at Module._compile (node:internal/modules/cjs/loader:1123:27)
at Module._extensions..js (node:internal/modules/cjs/loader:1213:10)
at Object.newLoader [as .ts] (/opt/nest-api/node_modules/pirates/lib/index.js:104:7)
at Module.load (node:internal/modules/cjs/loader:1037:32)
at Function.Module._load (node:internal/modules/cjs/loader:878:12)
at Module.require (node:internal/modules/cjs/loader:1061:19)
at require (node:internal/modules/cjs/helpers:103:18)
at /opt/nest-api/src/ts-migrate-mongoose/migrator.ts:519:28
at processTicksAndRejections (node:internal/process/task_queues:95:5)
at Migrator.runMigrations (/opt/nest-api/src/ts-migrate-mongoose/migrator.ts:518:31)
at Migrator.run (/opt/nest-api/src/ts-migrate-mongoose/migrator.ts:209:27)
at runMigrations (/opt/nest-api/src/migrator.ts:45:3)
at AppBootstrap.bootstrap (/opt/nest-api/src/main.ts:118:5)
But it works locally.
Start of my migration file:
import * as mongoose from 'mongoose';
import * as process from 'process';
import { migratorLog } from '../src/migrator';
export async function up(): Promise<void> {
...
}
Describe the bug Locally everything works well:
But it doesn’t work in kubernetes:
According to logs it gets stuck on dynamic import:
https://github.com/ilovepixelart/ts-migrate-mongoose/blob/15173ae49248d217e6e88edfb079fc3de0ad80f6/src/migrator.ts#L411
What could be the problem?
And what do empty curly braces (
{}
) at the end of logs mean?Additional context