K
Kysely12mo ago
crummy

[ERR_UNKNOWN_FILE_EXTENSION] when running migrations

I have a project with Sveltekit, TypeScript, and Kysely with SQLite. When I run my migrations, using the FileMigrationProvider, I get the following error:
TypeError [ERR_UNKNOWN_FILE_EXTENSION]: Unknown file extension ".ts" for /Users/crummy/code/finances/src/db/migrations/2023-06-22-initial.ts
at new NodeError (node:internal/errors:399:5)
at Object.getFileProtocolModuleFormat [as file:] (node:internal/modules/esm/get_format:79:11)
at defaultGetFormat (node:internal/modules/esm/get_format:121:38)
at defaultLoad (node:internal/modules/esm/load:81:20)
at nextLoad (node:internal/modules/esm/loader:163:28)
at ESMLoader.load (node:internal/modules/esm/loader:605:26)
at ESMLoader.moduleProvider (node:internal/modules/esm/loader:457:22)
at new ModuleJob (node:internal/modules/esm/module_job:64:26)
at #createModuleJob (node:internal/modules/esm/loader:480:17)
at ESMLoader.getModuleJob (node:internal/modules/esm/loader:434:34) {
code: 'ERR_UNKNOWN_FILE_EXTENSION'
}
TypeError [ERR_UNKNOWN_FILE_EXTENSION]: Unknown file extension ".ts" for /Users/crummy/code/finances/src/db/migrations/2023-06-22-initial.ts
at new NodeError (node:internal/errors:399:5)
at Object.getFileProtocolModuleFormat [as file:] (node:internal/modules/esm/get_format:79:11)
at defaultGetFormat (node:internal/modules/esm/get_format:121:38)
at defaultLoad (node:internal/modules/esm/load:81:20)
at nextLoad (node:internal/modules/esm/loader:163:28)
at ESMLoader.load (node:internal/modules/esm/loader:605:26)
at ESMLoader.moduleProvider (node:internal/modules/esm/loader:457:22)
at new ModuleJob (node:internal/modules/esm/module_job:64:26)
at #createModuleJob (node:internal/modules/esm/loader:480:17)
at ESMLoader.getModuleJob (node:internal/modules/esm/loader:434:34) {
code: 'ERR_UNKNOWN_FILE_EXTENSION'
}
What am I doing wrong?
Solution:
I got it working by avoiding FileMigrationProvider. Kind of hacky, not sure if there's a better way to do these imports: https://github.com/crummy/finances/commit/3b4ff5ce86a7767baa8ef3da2f279bbfc71d1ae0...
Jump to solution
14 Replies
Meithz (Razioner)
I had the same problem, there is a thread about it in the discord Are you on windows?
crummy
crummy12mo ago
ok windows? Not sure what you mean
Meithz (Razioner)
On windows?
crummy
crummy12mo ago
No, on a Mac.
Meithz (Razioner)
Not my same problem then Mine was because of how Esm module resolution works on windows
crummy
crummy12mo ago
GitHub
GitHub - Terbau/kysely-sveltekit-migration-error-recreation: Recrea...
Recreation of error. Contribute to Terbau/kysely-sveltekit-migration-error-recreation development by creating an account on GitHub.
Meithz (Razioner)
Is your code the same as in that repo? If not could you share yours?
crummy
crummy12mo ago
GitHub
GitHub - crummy/finances: Simple app to query transactions from an ...
Simple app to query transactions from an Akahu API - GitHub - crummy/finances: Simple app to query transactions from an Akahu API
crummy
crummy12mo ago
google seems to indicate I should remove type: "module" from package.json, but SvelteKit seems to return a bunch of errors when I do that
Solution
crummy
crummy12mo ago
I got it working by avoiding FileMigrationProvider. Kind of hacky, not sure if there's a better way to do these imports: https://github.com/crummy/finances/commit/3b4ff5ce86a7767baa8ef3da2f279bbfc71d1ae0
koskimas
koskimas12mo ago
That's no hacky at all. The reason we have the MigrationProvider abstraction is basically that you can do exactly that.
crummy
crummy12mo ago
Yeah.... Just felt a bit hacky to add the migrations in one place (the files) and then in another place (pointing the migration provider to them)
koskimas
koskimas12mo ago
Well that's what you have to do with some of these bundlers. You can't have dynamic imports
crummy
crummy12mo ago
Makes sense