Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Cloudflare Pages Deployment failing, __dirname is not defined #1194

Closed
AwesomeDude091 opened this issue Apr 27, 2023 · 4 comments
Closed

Cloudflare Pages Deployment failing, __dirname is not defined #1194

AwesomeDude091 opened this issue Apr 27, 2023 · 4 comments

Comments

@AwesomeDude091
Copy link

Environment

nuxt.config.ts

export default defineNuxtConfig({
    modules: ['@nuxtjs/tailwindcss', '@nuxt/image-edge', 'nuxt-unhead',
        'nuxt-simple-sitemap', 'nuxt-schema-org', 'nuxt-simple-robots']
});

Running Nuxt Version 3.4.2
.mvnrc
16

Reproduction

Upload this project to Cloudflare Pages using the Zero Config option provided by linking the GitHub Repository with Cloudflare Pages. Cloudflare successfully compiles and finds the _worker.js . It uploads the assets and fails on publishing a function

Describe the bug

Cloudflare Pages fails to deploy the application to the cloudflare network due to a reference error. It cannot find __dirname.

Additional context

The same project compiles successfully locally with the node_server preset and the cloudflare_pages preset.
I DO NOT add any Cloudflare Function (at least that I am aware of). I purely compile the nuxt web application and want it to execute :)

Logs

`Error: Failed to publish your Function. Got error: Uncaught ReferenceError: __dirname is not defined
  at functionsWorker-0.4740030691865005.js:6396:18`
@AwesomeDude091
Copy link
Author

After further investiagtion it seems that the issues resolves itself, once the @nuxt/image-edge module is removed from the application

Copy link
Member

Would you report this to https://github.com/nuxt/image/ with a reproduction? 🙏

@zsilbi
Copy link
Contributor

zsilbi commented Apr 28, 2023

@AwesomeDude091, I also ran into this a few days ago but didn't have time to report it in the nuxt/image repo.

After I removed the ipx dependecy (nuxt/image@99f5721), it worked on CloudFlare, so I think this issue can be closed here.

@Hebilicious
Copy link
Member

Closing in favour of related issue in nuxt/image nuxt/image#866

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

No branches or pull requests

4 participants