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

Corbado is not supported in recent versions of Node.js because it is not declared as an ESM module #386

Open
Fohlen opened this issue Jun 25, 2024 · 2 comments
Assignees

Comments

@Fohlen
Copy link

Fohlen commented Jun 25, 2024

Describe the bug
When I was trying out the Web SDK (@corbado/web-js) it could not transpile because Corbado is not an ESM module. I receive the following error:

(node:25781) Warning: To load an ES module, set "type": "module" in the package.json or use the .mjs extension.
(Use `node --trace-warnings ...` to show where the warning was created)
6:36:31 PM [vite] Error when evaluating SSR module /src/routes/+page.svelte: failed to import "@corbado/web-js"
|- /Users/fohlen/WebstormProjects/lesstax/node_modules/@corbado/web-js/dist/index.js:1

This is tailed by a long backtrace but boils down to using ESM.

To Reproduce
Steps to reproduce the behavior:

  1. Use Node 22, e.g 22.2.0 which is the latest via brew install node
  2. Create a Svelte project via npm create svelte@latest
  3. Install Corbado npm install --save @corbado/web-js
  4. Include it in some page import Corbado from '@corbado/web-js'
  5. Run npm run dev

Expected behavior

It should build in Node 22.

Additional context
According to StackOverflow, simply declaring the package type as:

"type": "module"

Should do the trick. Alternatively, declaring the output as .mjs will make it obvious for Node.js to pick up that it should use ESM over CommonJS.

@Fohlen
Copy link
Author

Fohlen commented Jun 25, 2024

I verified that adding "type": "module" to @corbado package configuration files is indeed a viable fix. That loads fine.

@incorbador incorbador self-assigned this Jul 8, 2024
@incorbador
Copy link
Contributor

@Fohlen thanks for reporting. Unfortunately we can't just switch web-js to a ESM module. Most likely we have to support both (esm and cjs) for some time. So this requires a bit of time and I have put this request on our roadmap.

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

2 participants