Import Mailgun from "mailgun.js";

I get this 10021 error leaving me stuck to use mailgun. Any ideas? “define” is the name of the mailgun function. My coding is all ok but the import of this particular module is the issue:

text: ‘A request to the Cloudflare API
(/accounts/57267b529e6d603103c1a98d4e7aa9ae/workers/scripts/contact-us/edge-preview) failed.’,
notes: [
{
text: ‘Uncaught ReferenceError: define is not defined\n’ +
’ at line 24 in node_modules/mailgun.js/mailgun.web.js\n’ +
’ at line 9 in __require\n’ +
’ at line 2282\n’ +
’ at line 2361\n’ +
’ [code: 10021]’
}
],
location: undefined,
kind: ‘error’,
code: 10021

2 Likes

I have a similar problem here. The define() function works just fine on my local machine (Vite Dev Server), but errors out on the Cloudflare Worker. Will look into this and circle back.

Great. Look forward to hear you

Any luck with solving the issue? I’ve run into the same.

I confirm. Node version and web version not working with this version of mailgun api library

Still a problem in 2024? Anyone got any ideas?

I ended up using Mailgun’s REST API, which works seamlessly on both BE and FE.

1 Like