image: Module causes "__dirname is not defined" error when deploying to Cloudflare Workers
Nuxt3 documents advise you can deploy to Cloudflare Workers. Guide can be found on the Nitro documentation.
The commands wrangler dev and wrangler publish work successfully when @nuxt/image-edge is commented out of the nuxt.config.ts file. However when adding adding it back I receive the following error:
Error: Something went wrong with the request to Cloudflare...
Uncaught ReferenceError: __dirname is not defined
at worker.js:1:918893
at worker.js:1:1051834
[API code: 10021]
Video attached showing it working with @nuxt/image-edge commented out and then adding it back resulting in the error.
About this issue
- Original URL
- State: closed
- Created 2 years ago
- Reactions: 11
- Comments: 25 (1 by maintainers)
This was resolved in the first RC with https://github.com/nuxt/image/pull/840 although until the next release, you will need to add the following line to your
nuxt.config:Also just experienced this
I’m encountering the same error:
In
nuxt.config.ts, I have set:Curiously, the error only occurs for our automatic CI deployment via Github actions. Manual deployment from my machine works.
Yup I just ran into the same. Any word on why this happens?
This probably has something to do with static site generation still not supported.