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

Support for ES6 modules #787

Closed
jcalfee opened this issue May 27, 2023 · 2 comments
Closed

Support for ES6 modules #787

jcalfee opened this issue May 27, 2023 · 2 comments

Comments

@jcalfee
Copy link

jcalfee commented May 27, 2023

Environment

nuxt@2.16.3
nuxt dev
node v18

Reproduction

Install per the README and add "type": "module" to package.json. Make an http page request..

Describe the bug

Startup and make a page request. The first page request shows an error that suggests that the nuxt bridge is compiling to commonjs code even thought the package is a module.

Additional context

No response

Logs

[web] New request: http://code.local:3000/
[web] [nuxt] [request error] [unhandled] [500] require() of ES Module /home/project/resp-val/.nuxt/dist/server/server.js not supported.
[web] server.js is treated as an ES module file as it is a .js file whose nearest parent package.json contains "type": "module" which declares all .js files in that package scope as ES modules.
[web] Instead rename server.js to end in .cjs, change the requiring code to use dynamic import() which is available in all CommonJS modules, or change "type": "module" to "type": "commonjs" in /home/project/resp-val/package.json to treat all .js files as CommonJS (using .mjs for all ES modules instead).
@wattanx
Copy link
Collaborator

wattanx commented Jun 13, 2023

It appears to be working in my environment.
https://stackblitz.com/edit/github-3fgb91-rng2di

Can you provide an environment to reproduce this?

@jcalfee
Copy link
Author

jcalfee commented Jun 13, 2023

Thanks for the feedback, I already changed paths though. Next time I'll try out those online stacks like you said, they look promising. I'm just going to http proxy this in using Nuxt 3.

@jcalfee jcalfee closed this as completed Jun 13, 2023
@danielroe danielroe mentioned this issue Jun 20, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants