Skip to content

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

@felixgabler

Description

@felixgabler

Environment

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

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