const MigratorLive = Layer.provide(
PgLive,
Migrator.makeLayer({
loader: Migrator.fromDisk(fileURLToPath(new URL('migrations', import.meta.url))),
schemaDirectory: 'src/migrations'
})
);
node:internal/process/promises:288
triggerUncaughtException(err, true /* fromPromise */);
^
[Error: {"reason":"import-error","message":"Could not import migration \"1_init\"\n\nError [ERR_UNSUPPORTED_ESM_URL_SCHEME]: Only URLs with a scheme in: file, data, and node are supported by the default ESM loader. On Windows, absolute paths must be valid file:// URLs. Received protocol 'd:'","_tag":"MigrationError"}] {
toJSON: [Function (anonymous)],
toString: [Function (anonymous)],
[Symbol(effect/Runtime/FiberFailure)]: Symbol(effect/Runtime/FiberFailure),
[Symbol(effect/Runtime/FiberFailure/Cause)]: {
_tag: 'Parallel',
left: { _tag: 'Empty' },
right: {
_tag: 'Fail',
error: {
reason: 'import-error',
message: 'Could not import migration "1_init"\n' +
'\n' +
"Error [ERR_UNSUPPORTED_ESM_URL_SCHEME]: Only URLs with a scheme in: file, data, and node are supported by the default ESM loader. On Windows, absolute paths must be valid file:// URLs. Received protocol 'd:'",
_tag: 'MigrationError'
}
}
},
[Symbol(nodejs.util.inspect.custom)]: [Function (anonymous)]
}
The migrator assumes that it can use
importhere: https://github.com/tim-smart/sqlfx/blob/main/packages/sql/src/Migrator/Node.ts#L32This makes the migrator fail in projects that haven't migrated over to ESM yet.
This also breaks on Windows where the following code breaks loading:
which fails with:
Related: nodejs/node#31710 nodejs/node#34765