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

Only URLs with a scheme in: file, data, and node are supported by the default ESM loader. #98

Closed
FaiezWaseem opened this issue Jun 17, 2024 · 10 comments

Comments

@FaiezWaseem
Copy link

Hi upon running node ace docs:generate it worked before , but now after adding vinejs and validations now on running this command suddenly i am getting this error

[ error ] Only URLs with a scheme in: file, data, and node are supported by the default ESM loader. On Windows, abs
olute paths must be valid file:// URLs. Received protocol 'c:' at throwIfUnsupportedURLScheme (node:internal/modules/esm/load:239:11)
at defaultLoad (node:internal/modules/esm/load:130:3)
at nextLoad (node:internal/modules/esm/hooks:750:28)
at C:\Development\web\node\adonijs-nextjs\server\node_modules\ts-node\src\esm.ts:255:45
at async addShortCircuitFlag (C:\Development\web\node\adonijs-nextjs\server\node_modules\ts-node\src\esm.
ts:409:15) at async nextLoad (node:internal/modules/esm/hooks:750:22)
at async Hooks.load (node:internal/modules/esm/hooks:383:20)
at async handleMessage (node:internal/modules/esm/worker:199:18)

@mGGk-fr
Copy link

mGGk-fr commented Jun 18, 2024

I have the same after updating to latest AdonisJS

@ad-on-is
Copy link
Owner

Oh boy... I hate the JS stack 🙄 will have a look into it

@ad-on-is
Copy link
Owner

Is this a Windows-only error, or a Node version error?
https://stackoverflow.com/questions/69665780/error-err-unsupported-esm-url-scheme-only-file-and-data-urls-are-supported-by

I can't reproduce it on Linux with Node v21.6.1

@ad-on-is
Copy link
Owner

I just deployed a possible fix in 3.47.0. Can you guys test it with that version? Otherwise I might need some help here from the windows folks.

@FaiezWaseem
Copy link
Author

@ad-on-is Ok i will test it now

@FaiezWaseem
Copy link
Author

well So I tried the update .
When i run the command node ace docs:generate , it runs successfully but when visits the docs
error1

But when i debug a little more i added this route

router.get('/swagger.json', async () => {
  const json = fs.readFile('swagger.json','utf8')
  return AutoSwagger.default.writeFile(json, swagger);
});

now its giving this error

out+error

but comment.ts exists , it have already created the swagger.json

swagger

here is the github repo of my project

Node v21.7.3
AdonisJs ^6.9.0
adonis-autoswagger ^3.47.0

@ad-on-is
Copy link
Owner

Thx for the reproduction... This is an issue with node ace serve --hmr
Using node ace serve --watch however, works as expected.

@ad-on-is
Copy link
Owner

@FaiezWaseem

Also... your config is wrong here.

router.get("/swagger", async () => {
  return router.toJSON()
});
router.get("/docs", async () => {
  return AutoSwagger.default.ui("/swagger", swagger);
});

should be

router.get("/swagger", async () => {
  return AutoSwagger.default.docs(swagger);
});
router.get("/docs", async () => {
  return AutoSwagger.default.ui("/swagger", swagger);
});

@ad-on-is
Copy link
Owner

Close in favor of #102

@FaiezWaseem
Copy link
Author

Yup fixed Working now

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants