N
Nuxt3w ago
grom

Nitro Error Building on CF Pages

I get this error:
[error] [nitro] Error: ENOTDIR: not a directory, stat '/opt/buildhome/repo/node_modules/unenv/dist/runtime/node/punycode.mjs/'
[error] [nitro] Error: ENOTDIR: not a directory, stat '/opt/buildhome/repo/node_modules/unenv/dist/runtime/node/punycode.mjs/'
when trying to build on cloudflare pages. The build worked as recently as yesterday, but does not work anymore after I made entirely unrelated changes. Any ideas? I've tried pinning the unenv version.
4 Replies
kapa.ai
kapa.ai3w ago
Hi @grom. I'm kapa.ai, your friendly support bot. I will try to answer your question by searching through the knowledge base. :wave: ---------------------- Based on the knowledge sources, your issue with Cloudflare Pages deployment appears to be related to recent changes in Nuxt's dependencies, particularly with unenv and nitropack. Several users have reported similar issues with Cloudflare deployments after upgrading to Nuxt 3.16.0, which includes changes to how unenv and Node.js compatibility are handled. The specific error you're seeing about punycode.mjs might be related to the Node.js 22 deprecation warning for the punycode module mentioned in one of the issues Github Issue #28819. Here are some potential solutions: 1. Update to the latest Nitropack version (2.11.6+) which includes fixes for Cloudflare deployments:
"overrides": {
"nitropack": "2.11.6"
}

"overrides": {
"nitropack": "2.11.6"
}

2. Enable Node.js compatibility in your Nuxt config:
defineNuxtConfig({
nitro: {
cloudflare: {
nodeCompat: true,
deployConfig: true,
}
}
})

defineNuxtConfig({
nitro: {
cloudflare: {
nodeCompat: true,
deployConfig: true,
}
}
})

3. Add compatibility flags to your wrangler.toml:
compatibility_flags = [ "nodejs_compat" ]

compatibility_flags = [ "nodejs_compat" ]

4. If the above doesn't work, you could try temporarily downgrading to Nitro 2.10.4 which some users reported as a working solution Github Issue #31257:
"overrides": {
"nitropack": "2.10.4"
}

"overrides": {
"nitropack": "2.10.4"
}

These issues appear to be related to changes in how Nuxt and Nitro handle Node.js compatibility in Cloudflare environments, particularly with the transition to unenv v2 which has different polyfill handling. If you're still experiencing issues, providing more details about your Nuxt version and configuration might help identify the specific cause. ---------------------- Note: you can ask me a follow up question by @ mentioning me again :speech_balloon: ----------------------
kapa.ai
kapa.ai3w ago
<@567320070951403531> Kapa.ai is still learning and improving, please let me know how I did by reacting below.
grom
gromOP3w ago
the weird part is it def shouldn't be a directory it's a file so i'm 98% sure it's not me
OwO
OwO5d ago
🚫 | doggnutts586, Create a team with the command owo team add {animal}

Did you find this page helpful?