Rhythm-Bot icon indicating copy to clipboard operation
Rhythm-Bot copied to clipboard

Fails on SyntaxError: Cannot use import statement outside a module

Open madsvcarlsen opened this issue 3 years ago • 2 comments

Not sure if this project is abandoned, but here goes, since an image was pushed 2 days ago; I'm using the latest docker image, and it fails with the following:

[email protected] start:prod /home/rhythmbot

NODE_ENV=production node --trace-warnings dist/app

== Migration20211031234554: migrating =======

/home/rhythmbot/migrations/Migration20211031234554.ts:1

import { Migration } from '@mikro-orm/migrations';

^^^^^^

SyntaxError: Cannot use import statement outside a module

at wrapSafe (internal/modules/cjs/loader.js:915:16)

at Module._compile (internal/modules/cjs/loader.js:963:27)

at Object.Module._extensions..js (internal/modules/cjs/loader.js:1027:10)

at Module.load (internal/modules/cjs/loader.js:863:32)

at Function.Module._load (internal/modules/cjs/loader.js:708:14)

at Module.require (internal/modules/cjs/loader.js:887:19)

at require (internal/modules/cjs/helpers.js:74:18)

at Migrator.resolve (/home/rhythmbot/node_modules/@mikro-orm/migrations/Migrator.js:141:27)

at Object.customResolver (/home/rhythmbot/node_modules/@mikro-orm/migrations/Migrator.js:43:44)

at Migration.migration (/home/rhythmbot/node_modules/umzug/lib/migration.js:60:38)

at /home/rhythmbot/node_modules/umzug/lib/migration.js:121:37

at Generator.next (<anonymous>)

at asyncGeneratorStep (/home/rhythmbot/node_modules/umzug/lib/migration.js:9:103)

at _next (/home/rhythmbot/node_modules/umzug/lib/migration.js:11:194)

at /home/rhythmbot/node_modules/umzug/lib/migration.js:11:364

at new Promise (<anonymous>)

[email protected] start:prod /home/rhythmbot

NODE_ENV=production node --trace-warnings dist/app

== Migration20211031234554: migrating =======

/home/rhythmbot/migrations/Migration20211031234554.ts:1

import { Migration } from '@mikro-orm/migrations';

^^^^^^

SyntaxError: Cannot use import statement outside a module

at wrapSafe (internal/modules/cjs/loader.js:915:16)

at Module._compile (internal/modules/cjs/loader.js:963:27)

at Object.Module._extensions..js (internal/modules/cjs/loader.js:1027:10)

at Module.load (internal/modules/cjs/loader.js:863:32)

at Function.Module._load (internal/modules/cjs/loader.js:708:14)

at Module.require (internal/modules/cjs/loader.js:887:19)

at require (internal/modules/cjs/helpers.js:74:18)

at Migrator.resolve (/home/rhythmbot/node_modules/@mikro-orm/migrations/Migrator.js:141:27)

at Object.customResolver (/home/rhythmbot/node_modules/@mikro-orm/migrations/Migrator.js:43:44)

at Migration.migration (/home/rhythmbot/node_modules/umzug/lib/migration.js:60:38)

at /home/rhythmbot/node_modules/umzug/lib/migration.js:121:37

at Generator.next (<anonymous>)

at asyncGeneratorStep (/home/rhythmbot/node_modules/umzug/lib/migration.js:9:103)

at _next (/home/rhythmbot/node_modules/umzug/lib/migration.js:11:194)

at /home/rhythmbot/node_modules/umzug/lib/migration.js:11:364

at new Promise (<anonymous>)

madsvcarlsen avatar Nov 01 '21 00:11 madsvcarlsen

@dudeofawesome Not sure if you've encountered this, but it seems like migrations isn't getting parsed correctly when run through docker. Maybe "start:prod" needs to be run with ts-node?

Malexion avatar Nov 01 '21 21:11 Malexion

I can confirm, that using only 'start' which registers ts-node works with the latest image.

madsvcarlsen avatar Nov 01 '21 22:11 madsvcarlsen