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

ESM path failure when importing a template #901

Closed
thechucklingatom opened this issue Aug 23, 2024 · 4 comments · Fixed by #930
Closed

ESM path failure when importing a template #901

thechucklingatom opened this issue Aug 23, 2024 · 4 comments · Fixed by #930
Labels
bug Something isn't working

Comments

@thechucklingatom
Copy link
Contributor

Hello, I am seeing an issue when importing a custom template on windows.

$ swagger-typescript-api -p http://localhost:5005/swagger/v1/swagger.json -o ./src -n api.ts --module-name-index 1 --custom-config custom-config.cjs -t ./templates
Error loading custom config 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 'm:'
    at throwIfUnsupportedURLScheme (node:internal/modules/esm/load:239:11)
    at defaultLoad (node:internal/modules/esm/load:130:3)
    at ModuleLoader.load (node:internal/modules/esm/loader:403:13)
    at ModuleLoader.moduleProvider (node:internal/modules/esm/loader:285:56)
    at new ModuleJob (node:internal/modules/esm/module_job:67:26)
    at #createModuleJob (node:internal/modules/esm/loader:297:17)
    at ModuleLoader.getJobFromResolveResult (node:internal/modules/esm/loader:254:34)
    at ModuleLoader.getModuleJob (node:internal/modules/esm/loader:235:17)
    at async ModuleLoader.import (node:internal/modules/esm/loader:322:23) {
  code: 'ERR_UNSUPPORTED_ESM_URL_SCHEME'

in this case the external drive is named m: and what I believe is causing the problem. It does not know how to load the file correctly. When running the same command from my linux machine with the same structure everything runs successfully. I believe this import approach will resolve the issue. I am happy to make a PR for this fix if preferred.

@IhnatKlimchuk
Copy link

This commit broke generation for me as well

@thechucklingatom
Copy link
Contributor Author

Any input on this issue? I would like to try to get this merged in.

@xTinaIsSterling
Copy link

I am also having trouble with this. Is there any update on a fix?

@VeXell
Copy link

VeXell commented Oct 27, 2024

Can have a look on it please. And merge pull request.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
5 participants