Skip to content

Can't build Nuxt app with Cloudflare preset #772

@gabrielmfern

Description

@gabrielmfern

Describe the Bug

Running the build with the cloudflare preset

npx nuxi build --preset=cloudflare_pages

In a Nuxt app that imports and tries to send an email errors with

[nitro 12:13:43 PM]  ERROR  Error: Cannot resolve "@react-email/render" from ".../nuxt-resend-node-cloudflare/node_modules/.pnpm/resend@6.6.0/node_modules/resend/dist/index.mjs" and externals are not allowed!

[12:13:43 PM]  ERROR  Cannot resolve "@react-email/render" from ".../nuxt-resend-node-cloudflare/node_modules/.pnpm/resend@6.6.0/node_modules/resend/dist/index.mjs" and externals are not allowed!

    at Object.resolveId (node_modules/.pnpm/nitropack@2.12.9/node_modules/nitropack/dist/rollup/index.mjs:2011:17)
    at async PluginDriver.hookFirstAndGetPlugin (node_modules/.pnpm/rollup@4.54.0/node_modules/rollup/dist/es/shared/node-entry.js:22404:28)
    at async resolveId (node_modules/.pnpm/rollup@4.54.0/node_modules/rollup/dist/es/shared/node-entry.js:20880:26)
    at async ModuleLoader.resolveId (node_modules/.pnpm/rollup@4.54.0/node_modules/rollup/dist/es/shared/node-entry.js:21317:15)
    at async Object.resolveId (node_modules/.pnpm/@rollup+plugin-commonjs@28.0.9_rollup@4.54.0/node_modules/@rollup/plugin-commonjs/dist/es/index.js:617:10)
    at async PluginDriver.hookFirstAndGetPlugin (node_modules/.pnpm/rollup@4.54.0/node_modules/rollup/dist/es/shared/node-entry.js:22404:28)
    at async resolveId (node_modules/.pnpm/rollup@4.54.0/node_modules/rollup/dist/es/shared/node-entry.js:20880:26)
    at async ModuleLoader.resolveId (node_modules/.pnpm/rollup@4.54.0/node_modules/rollup/dist/es/shared/node-entry.js:21317:15)
    at async ModuleLoader.resolveDynamicImport (node_modules/.pnpm/rollup@4.54.0/node_modules/rollup/dist/es/shared/node-entry.js:21721:82)
    at async node_modules/.pnpm/rollup@4.54.0/node_modules/rollup/dist/es/shared/node-entry.js:21605:32

Link to the code that reproduces this issue

https://github.com/gabrielmfern/nuxt-resend-node-cloudflare

To Reproduce

1. Install dependencies

pnpm install

2. Run build with Cloudflare pages preset

npx nuxi build --preset=cloudflare_pages

3. See the errors on the optional dynamic import

[nitro 12:13:43 PM]  ERROR  Error: Cannot resolve "@react-email/render" from 
".../nuxt-resend-node-cloudflare/node_modules/.pnpm/resend@6.6.0/node_modules/resend/dist/index.mjs" 
and externals are not allowed!

Expected Behavior

The build to run properly without any errors when I'm not using the react option.

What's your node version? (if relevant)

24.12.0

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions