Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: fixed ES Module loading with abolute path fails on windows #430

Closed

Conversation

MrMenezesDev
Copy link

Fixed error on windows

Error [ERR_UNSUPPORTED_ESM_URL_SCHEME]: Only URLs with a scheme in: file and data are supported by the default ESM loader. On Windows, absolute paths must be valid file:// URLs. Received protocol 'c:'
at new NodeError (node:internal/errors:399:5)
at throwIfUnsupportedURLScheme (node:internal/modules/esm/resolve:1059:11)
at defaultResolve (node:internal/modules/esm/resolve:1135:3)
at nextResolve (node:internal/modules/esm/loader:163:28)
at defer (C:\Projetos\cubos\api-typescript-sdkgen-kysely\node_modules.pnpm\ts-node@10.9.1_@swc+core@1.3.49_@types[email protected][email protected]\node_modules\ts-node\src\esm.ts:159:23)
at entrypointFallback (C:\Projetos\cubos\api-typescript-sdkgen-kysely\node_modules.pnpm\ts-node@10.9.1_@swc+core@1.3.49_@types[email protected][email protected]\node_modules\ts-node\src\esm.ts:168:34)
at C:\Projetos\cubos\api-typescript-sdkgen-kysely\node_modules.pnpm\ts-node@10.9.1_@swc+core@1.3.49_@types[email protected][email protected]\node_modules\ts-node\src\esm.ts:202:16
at addShortCircuitFlag (C:\Projetos\cubos\api-typescript-sdkgen-kysely\node_modules.pnpm\ts-node@10.9.1_@swc+core@1.3.49_@types[email protected][email protected]\node_modules\ts-node\src\esm.ts:409:21)
at resolve (C:\Projetos\cubos\api-typescript-sdkgen-kysely\node_modules.pnpm\ts-node@10.9.1_@swc+core@1.3.49_@types[email protected][email protected]\node_modules\ts-node\src\esm.ts:197:12)
at nextResolve (node:internal/modules/esm/loader:163:28)

@koskimas
Copy link
Member

And breaks migration on all other platforms...

@koskimas koskimas closed this Apr 18, 2023
@igalklebanov igalklebanov added bug Something isn't working invalid This doesn't seem right labels Apr 18, 2023
@MrMenezesDev
Copy link
Author

Is there any platform identifier in any utils module that you can use?

@koskimas
Copy link
Member

Unfortunately no since Kysely is platform independent. There's no API (that I know of) that works on node, deno, bun, the browsers and all other javascript environments that can be used to check the platform.

@mtt-artis
Copy link

mtt-artis commented Aug 23, 2023

@koskimas

i link this for info nodejs/node#31710

would it be possible to add a fileProtocol param to the FileMigrationProviderr interface
where the end user could provide "file://" if he needs to
the user could use the api of the plateform to detect it, it would be his responsability

@mtt-artis mtt-artis mentioned this pull request Aug 23, 2023
@mtt-artis
Copy link

mtt-artis commented Aug 24, 2023

@koskimas
actually "file://" works on windows and linux in esm

edit : remove code because of typescript error

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working invalid This doesn't seem right
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants