"Unexpected token 'export'" when using a primitive module from Cloudflare online worker editor
Screenshot of the error is attached.
5 Replies
Does this help
https://developers.cloudflare.com/workers/reference/migrate-to-module-workers/#migrate-a-worker
Cloudflare Docs
Migrate from Service Workers to ES Modules | Cloudflare Workers docs
Write your Worker code in ES modules syntax for an optimized experience.
Thanks, but tried already with no luck. It seems that ES modules support somehow not activated in the Cloudflare Workers wed editor.
I've tried to rename existing default worker.js file extension to mjs, but each time I open web editor it is being overwritten to the current version.
What happens if you create a new worker?
The quick editor in the dashboard can be a little finnicky when transitioning from Service Worker -> ES Modules
Tried, new worker creates with ES module based boilerplate be default with no error like mine.
Yeah in that case, I would recommend you create a new worker, or use
wrangler
to manage and publish your workers