K
Kysely2y 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
crummyOP2y ago
ok windows? Not sure what you mean
Meithz (Razioner)
On windows?
crummy
crummyOP2y ago
No, on a Mac.
Meithz (Razioner)
Not my same problem then Mine was because of how Esm module resolution works on windows
crummy
crummyOP2y 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
crummyOP2y 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
crummyOP2y 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
crummy2y 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
koskimas2y ago
That's no hacky at all. The reason we have the MigrationProvider abstraction is basically that you can do exactly that.
crummy
crummyOP2y 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
koskimas2y ago
Well that's what you have to do with some of these bundlers. You can't have dynamic imports
crummy
crummyOP2y ago
Makes sense
Want results from more Discord servers?
Add your server