Skip to content

Build fails with ENOTDIR error for _unenv/workerd/process.mjs when using cloudflare-pages preset #3271

Description

@felixgabler

Environment

  • Operating System: Darwin
  • Node Version: v22.11.0
  • Nuxt Version: 3.16.2
  • CLI Version: 3.24.0
  • Nitro Version: 2.11.8
  • Package Manager: bun@1.2.7
  • Builder: -
  • User Config: compatibilityDate, modules, devtools, imports, components, css, runtimeConfig, routeRules, app, supabase, i18n, cookieControl, $production, stripe, sitemap, pwa, router, sourcemap, sentry, build, eslint, nitro, vite
  • Runtime Modules: ./modules/supabase-nuxt/src/module.ts, @unlok-co/nuxt-stripe@4.0.2, nuxt-i18n-micro@1.83.0, @nuxtjs/fontaine@0.5.0, @vueuse/nuxt@13.0.0, @nuxtjs/sitemap@7.2.9, @dargmuesli/nuxt-cookie-control@8.6.1, floating-vue/nuxt@5.2.2, @nuxt/eslint@1.3.0, @vite-pwa/nuxt@1.0.0, @nuxt/scripts@0.11.5, @sentry/nuxt/module@9.10.1, @nuxthub/core@0.8.23
  • Build Modules: -

Reproduction

Will try to set up a repository with a reproduction asap but wanted to already get this out here

Describe the bug

When attempting to build a Nuxt 3.16.2 project using the cloudflare-pages preset (required for Nuxt Hub deployment), the build fails during the Nitro server build step.

The specific error is:

[nitro 4:52:56 PM] ERROR Error: Could not load /my-project/node_modules/nitropack/dist/presets/_unenv/workerd/process.mjs/: ENOTDIR: not a directory, open '/my-project/node_modules/nitropack/dist/presets/_unenv/workerd/process.mjs/'

This suggests that the build process is incorrectly appending a trailing slash and trying to read the file node_modules/nitropack/dist/presets/_unenv/workerd/process.mjs as if it were a directory.

Additional context

  • This error occurs specifically when using the cloudflare-pages preset.
  • We are considering a migration from Vercel to Nuxt Hub, and this error is blocking our deployment and evaluation process.
  • We previously encountered an issue with papaparse similar to nitrojs/nitro#3071 which was resolved by adding a replace rule to the nitro config, but this ENOTDIR error seems unrelated.
  • The problematic file appears to be related to Node.js process polyfills for the Cloudflare Workers environment: nitrojs/nitro/.../process.mjs

Logs

[nitro 5:15:31 PM] ℹ Building Nuxt Nitro server (preset: cloudflare-pages, compatibility date: 2024-07-05)
node_modules/mime/dist/src/Mime.js (1:30): The 'this' keyword is equivalent to 'undefined' at the top level of an ES module, and has been rewritten
node_modules/mime/dist/src/Mime.js (1:38): The 'this' keyword is equivalent to 'undefined' at the top level of an ES module, and has been rewritten
node_modules/@opentelemetry/api/build/esm/metrics/NoopMeter.js (16:17): The 'this' keyword is equivalent to 'undefined' at the top level of an ES module, and has been rewritten
node_modules/@opentelemetry/api/build/esm/metrics/NoopMeter.js (16:25): The 'this' keyword is equivalent to 'undefined' at the top level of an ES module, and has been rewritten
node_modules/openai/core.mjs (1:30): The 'this' keyword is equivalent to 'undefined' at the top level of an ES module, and has been rewritten
node_modules/openai/core.mjs (1:38): The 'this' keyword is equivalent to 'undefined' at the top level of an ES module, and has been rewritten
node_modules/openai/core.mjs (7:30): The 'this' keyword is equivalent to 'undefined' at the top level of an ES module, and has been rewritten
node_modules/openai/core.mjs (7:38): The 'this' keyword is equivalent to 'undefined' at the top level of an ES module, and has been rewritten
node_modules/@anthropic-ai/sdk/core.mjs (1:30): The 'this' keyword is equivalent to 'undefined' at the top level of an ES module, and has been rewritten
node_modules/@anthropic-ai/sdk/core.mjs (1:38): The 'this' keyword is equivalent to 'undefined' at the top level of an ES module, and has been rewritten
node_modules/@anthropic-ai/sdk/core.mjs (7:30): The 'this' keyword is equivalent to 'undefined' at the top level of an ES module, and has been rewritten
node_modules/@anthropic-ai/sdk/core.mjs (7:38): The 'this' keyword is equivalent to 'undefined' at the top level of an ES module, and has been rewritten
node_modules/@opentelemetry/api/build/esm/api/context.js (16:14): The 'this' keyword is equivalent to 'undefined' at the top level of an ES module, and has been rewritten
node_modules/@opentelemetry/api/build/esm/api/context.js (16:22): The 'this' keyword is equivalent to 'undefined' at the top level of an ES module, and has been rewritten
node_modules/@opentelemetry/api/build/esm/api/context.js (32:21): The 'this' keyword is equivalent to 'undefined' at the top level of an ES module, and has been rewritten
node_modules/@opentelemetry/api/build/esm/api/context.js (32:29): The 'this' keyword is equivalent to 'undefined' at the top level of an ES module, and has been rewritten
node_modules/@opentelemetry/api/build/esm/api/diag.js (16:14): The 'this' keyword is equivalent to 'undefined' at the top level of an ES module, and has been rewritten
node_modules/@opentelemetry/api/build/esm/api/diag.js (16:22): The 'this' keyword is equivalent to 'undefined' at the top level of an ES module, and has been rewritten
node_modules/@opentelemetry/api/build/esm/api/diag.js (32:21): The 'this' keyword is equivalent to 'undefined' at the top level of an ES module, and has been rewritten
node_modules/@opentelemetry/api/build/esm/api/diag.js (32:29): The 'this' keyword is equivalent to 'undefined' at the top level of an ES module, and has been rewritten
node_modules/@opentelemetry/api/build/esm/baggage/internal/baggage-impl.js (16:14): The 'this' keyword is equivalent to 'undefined' at the top level of an ES module, and has been rewritten
node_modules/@opentelemetry/api/build/esm/baggage/internal/baggage-impl.js (16:22): The 'this' keyword is equivalent to 'undefined' at the top level of an ES module, and has been rewritten
node_modules/@opentelemetry/api/build/esm/baggage/internal/baggage-impl.js (32:16): The 'this' keyword is equivalent to 'undefined' at the top level of an ES module, and has been rewritten
node_modules/@opentelemetry/api/build/esm/baggage/internal/baggage-impl.js (32:24): The 'this' keyword is equivalent to 'undefined' at the top level of an ES module, and has been rewritten
node_modules/openai/lib/responses/ResponseStream.mjs (1:30): The 'this' keyword is equivalent to 'undefined' at the top level of an ES module, and has been rewritten
node_modules/openai/lib/responses/ResponseStream.mjs (1:38): The 'this' keyword is equivalent to 'undefined' at the top level of an ES module, and has been rewritten
node_modules/openai/lib/responses/ResponseStream.mjs (7:30): The 'this' keyword is equivalent to 'undefined' at the top level of an ES module, and has been rewritten
node_modules/openai/lib/responses/ResponseStream.mjs (7:38): The 'this' keyword is equivalent to 'undefined' at the top level of an ES module, and has been rewritten
node_modules/@opentelemetry/api/build/esm/diag/ComponentLogger.js (16:14): The 'this' keyword is equivalent to 'undefined' at the top level of an ES module, and has been rewritten
node_modules/@opentelemetry/api/build/esm/diag/ComponentLogger.js (16:22): The 'this' keyword is equivalent to 'undefined' at the top level of an ES module, and has been rewritten
node_modules/@opentelemetry/api/build/esm/diag/ComponentLogger.js (32:21): The 'this' keyword is equivalent to 'undefined' at the top level of an ES module, and has been rewritten
node_modules/@opentelemetry/api/build/esm/diag/ComponentLogger.js (32:29): The 'this' keyword is equivalent to 'undefined' at the top level of an ES module, and has been rewritten
node_modules/@opentelemetry/api/build/esm/context/NoopContextManager.js (16:14): The 'this' keyword is equivalent to 'undefined' at the top level of an ES module, and has been rewritten
node_modules/@opentelemetry/api/build/esm/context/NoopContextManager.js (16:22): The 'this' keyword is equivalent to 'undefined' at the top level of an ES module, and has been rewritten
node_modules/@opentelemetry/api/build/esm/context/NoopContextManager.js (32:21): The 'this' keyword is equivalent to 'undefined' at the top level of an ES module, and has been rewritten
node_modules/@opentelemetry/api/build/esm/context/NoopContextManager.js (32:29): The 'this' keyword is equivalent to 'undefined' at the top level of an ES module, and has been rewritten
node_modules/@anthropic-ai/sdk/lib/MessageStream.mjs (1:30): The 'this' keyword is equivalent to 'undefined' at the top level of an ES module, and has been rewritten
node_modules/@anthropic-ai/sdk/lib/MessageStream.mjs (1:38): The 'this' keyword is equivalent to 'undefined' at the top level of an ES module, and has been rewritten
node_modules/@anthropic-ai/sdk/lib/MessageStream.mjs (7:30): The 'this' keyword is equivalent to 'undefined' at the top level of an ES module, and has been rewritten
node_modules/@anthropic-ai/sdk/lib/MessageStream.mjs (7:38): The 'this' keyword is equivalent to 'undefined' at the top level of an ES module, and has been rewritten
node_modules/openai/internal/decoders/line.mjs (1:30): The 'this' keyword is equivalent to 'undefined' at the top level of an ES module, and has been rewritten
node_modules/openai/internal/decoders/line.mjs (1:38): The 'this' keyword is equivalent to 'undefined' at the top level of an ES module, and has been rewritten
node_modules/openai/internal/decoders/line.mjs (7:30): The 'this' keyword is equivalent to 'undefined' at the top level of an ES module, and has been rewritten
node_modules/openai/internal/decoders/line.mjs (7:38): The 'this' keyword is equivalent to 'undefined' at the top level of an ES module, and has been rewritten
node_modules/openai/lib/EventStream.mjs (1:30): The 'this' keyword is equivalent to 'undefined' at the top level of an ES module, and has been rewritten
node_modules/openai/lib/EventStream.mjs (1:38): The 'this' keyword is equivalent to 'undefined' at the top level of an ES module, and has been rewritten
node_modules/openai/lib/EventStream.mjs (7:30): The 'this' keyword is equivalent to 'undefined' at the top level of an ES module, and has been rewritten
node_modules/openai/lib/EventStream.mjs (7:38): The 'this' keyword is equivalent to 'undefined' at the top level of an ES module, and has been rewritten
node_modules/@anthropic-ai/sdk/internal/decoders/line.mjs (1:30): The 'this' keyword is equivalent to 'undefined' at the top level of an ES module, and has been rewritten
node_modules/@anthropic-ai/sdk/internal/decoders/line.mjs (1:38): The 'this' keyword is equivalent to 'undefined' at the top level of an ES module, and has been rewritten
node_modules/@anthropic-ai/sdk/internal/decoders/line.mjs (7:30): The 'this' keyword is equivalent to 'undefined' at the top level of an ES module, and has been rewritten
node_modules/@anthropic-ai/sdk/internal/decoders/line.mjs (7:38): The 'this' keyword is equivalent to 'undefined' at the top level of an ES module, and has been rewritten
node_modules/openai/lib/AssistantStream.mjs (1:30): The 'this' keyword is equivalent to 'undefined' at the top level of an ES module, and has been rewritten
node_modules/openai/lib/AssistantStream.mjs (1:38): The 'this' keyword is equivalent to 'undefined' at the top level of an ES module, and has been rewritten
node_modules/openai/lib/AssistantStream.mjs (6:30): The 'this' keyword is equivalent to 'undefined' at the top level of an ES module, and has been rewritten
node_modules/openai/lib/AssistantStream.mjs (6:38): The 'this' keyword is equivalent to 'undefined' at the top level of an ES module, and has been rewritten
node_modules/@anthropic-ai/sdk/lib/BetaMessageStream.mjs (1:30): The 'this' keyword is equivalent to 'undefined' at the top level of an ES module, and has been rewritten
node_modules/@anthropic-ai/sdk/lib/BetaMessageStream.mjs (1:38): The 'this' keyword is equivalent to 'undefined' at the top level of an ES module, and has been rewritten
node_modules/@anthropic-ai/sdk/lib/BetaMessageStream.mjs (7:30): The 'this' keyword is equivalent to 'undefined' at the top level of an ES module, and has been rewritten
node_modules/@anthropic-ai/sdk/lib/BetaMessageStream.mjs (7:38): The 'this' keyword is equivalent to 'undefined' at the top level of an ES module, and has been rewritten
node_modules/openai/lib/ChatCompletionStream.mjs (1:30): The 'this' keyword is equivalent to 'undefined' at the top level of an ES module, and has been rewritten
node_modules/openai/lib/ChatCompletionStream.mjs (1:38): The 'this' keyword is equivalent to 'undefined' at the top level of an ES module, and has been rewritten
node_modules/openai/lib/ChatCompletionStream.mjs (7:30): The 'this' keyword is equivalent to 'undefined' at the top level of an ES module, and has been rewritten
node_modules/openai/lib/ChatCompletionStream.mjs (7:38): The 'this' keyword is equivalent to 'undefined' at the top level of an ES module, and has been rewritten
node_modules/openai/lib/AbstractChatCompletionRunner.mjs (1:30): The 'this' keyword is equivalent to 'undefined' at the top level of an ES module, and has been rewritten
node_modules/openai/lib/AbstractChatCompletionRunner.mjs (1:38): The 'this' keyword is equivalent to 'undefined' at the top level of an ES module, and has been rewritten

[nitro 5:16:21 PM]  ERROR  Error: Could not load /my-project/node_modules/nitropack/dist/presets/_unenv/workerd/process.mjs/: ENOTDIR: not a directory, open '/my-project/node_modules/nitropack/dist/presets/_unenv/workerd/process.mjs/'


undefined


[5:16:21 PM]  ERROR  Could not load /my-project/node_modules/nitropack/dist/presets/_unenv/workerd/process.mjs/: ENOTDIR: not a directory, open '/my-project/node_modules/nitropack/dist/presets/_unenv/workerd/process.mjs/'

    at async open (node:internal/fs/promises:638:25)
    at async readFile (node:internal/fs/promises:1238:14)
    at async node_modules/rollup/dist/es/shared/node-entry.js:21005:24
    at async Queue.work (node_modules/rollup/dist/es/shared/node-entry.js:22231:32) 



[5:16:21 PM]  ERROR  Could not load /my-project/node_modules/nitropack/dist/presets/_unenv/workerd/process.mjs/: ENOTDIR: not a directory, open '/my-project/node_modules/nitropack/dist/presets/_unenv/workerd/process.mjs/'

error: script "build" exited with code 1

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions