fix: enable Node.js compatibility for Cloudflare Workers#780
Merged
atinux merged 1 commit intonuxt-hub:mainfrom Jan 16, 2026
Merged
fix: enable Node.js compatibility for Cloudflare Workers#780atinux merged 1 commit intonuxt-hub:mainfrom
atinux merged 1 commit intonuxt-hub:mainfrom
Conversation
|
@onmax is attempting to deploy a commit to the NuxtLabs Team on Vercel. A member of the Team first needs to authorize it. |
commit: |
Contributor
|
Weird because I disabled it to set the compat flag manually, let's try with your fix |
atinux
approved these changes
Jan 16, 2026
|
When will this be included in a new release? |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Closes #711
Summary
nodeCompat = falsewas accidentally shipped in v0.10.1, breaking Node.js crypto APIs on Cloudflare Workers. Password verification with scrypt fails silently.StackBlitz
CLI Reproduction
Verify fix
Investigation Details
Git History
The bug originated in commit
b00d094("chore: try to set compat flag manually") during a debugging session:Later moved to
cloudflare.tsin PR #720 (cec8c89), keepingnodeCompat = false.The comment says "// Enable Cloudflare Node.js compatibility" but the code disables it.
Why Two Things Are Needed
Cloudflare Workers Node.js compatibility requires two layers:
nodeCompat: trueunenvCfNodeCompatpreset, marksnode:*as externalnodejs_compatflagFrom Nitro source (
src/presets/cloudflare/utils.ts):The
unenvCfNodeCompatpreset marksnode:cryptoand other modules as external, so rollup leavesimport 'node:crypto'as-is instead of bundling polyfills.What Went Wrong
NuxtHub was setting:
nodeCompat = false→ unenv preset NOT applied → rollup bundles broken polyfillsnodejs_compatflag in wrangler.json → runtime can provide modules, but bundler already polyfilled themResult: incomplete crypto polyfills at build time. User @raress96 confirmed:
[unenv] crypto.createHash is not implemented yet!Build Output Comparison
nitro.mjssizenodeCompat: false)nodeCompat: true)node:cryptoexternal