-
-
Notifications
You must be signed in to change notification settings - Fork 313
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
Cloudflare: The requested module 'node:crypto' does not provide an export named 'constants' #659
Comments
Quite possibly. Every bundler worth its salt knows to target the Web API / Browser build for workerd. I'll add an explicit target just to be sure but you should ask in workerd / bundler of your choice on why a node.js target is used over a browser one. |
I'm running into the same issue. @thdxr, how did you resolve it? I'm trying to add a new hono middleware for propelauth based on the clerk-auth middleware. > wrangler dev src/index.ts
⛅️ wrangler 3.53.1
-------------------
Using vars defined in .dev.vars
Your worker has access to the following bindings:
- Vars:
- APP_ENV: "dev"
- SENTRY_DSN: "(hidden)"
[wrangler:inf] Ready on http://localhost:51665
⎔ Starting local server...
✘ [ERROR] service core:user:my-app-api: Uncaught SyntaxError: The requested module 'node:crypto' does not provide an export named 'constants' Edit: I think I have a hunch. I had Edit2: How does |
Lines 79 to 86 in fd46e2c
It would appear the nodejs_compat flag makes your bundle process target the nodejs conditional export for which the underlying the |
@panva I found the proposal that introduced those runtime keys. Still, I couldn't find a source on how those conditional export hints impact the bundling within Cloudflare's wrangler (with/without the node compatibility flag). Would you happen to have any pointers? |
I would not. You need to ask your bundler or stop using node compat if you want to depend on modules whos compat level is not sufficient. I've added a warning to #265 |
What happened?
it seems like jose depends on
constants
fromnode:crypto
which is not yet available in cloudflare workers.is it possible i'm packaging it wrong?
Version
5.2.1
Runtime
Cloudflare Workers
Runtime Details
workers
Code to reproduce
Required
The text was updated successfully, but these errors were encountered: