Skip to content

Failed to publish your Function. Got error: Uncaught ReferenceError: require is not defined #534

@gitcarter

Description

@gitcarter

I've been deploying via nuxt hub for weeks, but now I am getting the following error at the Deploying to Cloudflare's global network stage of a build:

Failed to publish your Function. Got error: Uncaught ReferenceError: require is not defined
  at chunks/nitro/nitro.mjs:13:1420247
  at chunks/nitro/nitro.mjs:13:1421804

After receiving this error the first time, I updated @nuxthub/core to 0.8.17 and wrangler to 4.8.0 in case there were some breaking changes I needed to update with, but neither fixed my issue.

Not sure if this would help but here's a snippet of the pipeline logs:

npx nuxthub deploy
NuxtHub CLI                                                                                                                                                                                   7:10:39 PM
✔ Connected to [gituser] team.                                                                                                                                                               7:10:40 PM
✔ Linked to [project-slug] project.                                                                                                                                                           7:10:40 PM
ℹ Building the Nuxt project...                                                                                                                                                               7:10:40 PM
✔ NuxtHub Core module is installed and registered in the project.                                                                                                                            7:10:40 PM
Nuxt 3.16.2 with Nitro 2.11.8                                                                                                                                                           nuxi  7:10:41 PM
ℹ Using default Tailwind CSS file                                                                                                                                           nuxt:tailwindcss 7:10:41 PM
ℹ Nuxt Icon server bundle mode is set to remote                                                                                                                                              7:10:42 PM
ℹ Running with compatibility version 4                                                                                                                                                  nuxt 7:10:42 PM
ℹ Building for Nitro preset: cloudflare-pages                                                                                                                                          nuxi  7:10:42 PM
ℹ Building client...                                                                                                                                                                         7:10:44 PM
ℹ vite v6.2.5 building for production...                                                                                                                                                     7:10:44 PM
ℹ ✓ 1209 modules transformed.  

[...a bunch of bundling]

ℹ ✓ built in 5.83s                                                                                                                                                                           7:10:50 PM
✔ Client built in 5836ms                                                                                                                                                                     7:10:50 PM
ℹ Building server...                                                                                                                                                                         7:10:50 PM
ℹ vite v6.2.5 building SSR bundle for production...                                                                                                                                          7:10:50 PM
ℹ ✓ 630 modules transformed.                                                                                                                                                                 7:10:53 PM
ℹ ✓ built in 4.02s                                                                                                                                                                           7:10:54 PM
✔ Server built in 4024ms 

✔ Generated public dist                                                                                                                                                                nitro 7:10:54 PM
ℹ Database migrations and queries included in build                                                                                                                                 nuxt:hub 7:10:54 PM
ℹ Building Nuxt Nitro server (preset: cloudflare-pages, compatibility date: 2024-07-03)                                                                                                nitro 7:10:54 PM
node_modules/.pnpm/mime@4.0.7/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/.pnpm/mime@4.0.7/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
✔ Nuxt Nitro server built 

[...a bunch of dist chunks]

Σ Total size: 5.74 MB (1.61 MB gzip)
ℹ Generated dist/_routes.json                                                                                                                                                                7:11:23 PM
ℹ Generated dist/_headers                                                                                                                                                                    7:11:23 PM
ℹ Generated dist/_redirects                                                                                                                                                                  7:11:23 PM
✔ You can preview this build using npx nuxthub preview                                                                                                                                 nitro 7:11:23 PM
✔ You can deploy this build using npx nuxthub deploy                                                                                                                                   nitro 7:11:23 PM
✔ pet-syn-q-web ready to deploy.
✔ 2 new static assets uploaded (254 B)
ℹ 89 static assets (4.56 MB / 3.63 MB gzip)                                                                                                                                                  7:11:26 PM
ℹ 338 server files (5.74 MB / 1.61 MB gzip)...                                                                                                                                               7:11:26 PM
✔ Found 26 database migrations on pet-syn-q-web
ℹ No pending database migrations to apply.                                                                                                                                                   7:11:28 PM
✖ Failed to deploy [project-slug] to preview.

 ERROR  Failed to publish your Function. Got error: Uncaught ReferenceError: require is not defined                                                                                           7:11:41 PM
  at chunks/nitro/nitro.mjs:13:1420247
  at chunks/nitro/nitro.mjs:13:1421804


Any thoughts?

Metadata

Metadata

Assignees

No one assigned

    Labels

    questionFurther information is requested

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions