Introduction
Cloudflare in their documentation propose to use mimetext for sending emails in their Cloudflare Workers and Cloudflare Email Workers.
The problem
Since updating to version 3.0.21 (although it could be any version after 3.0.16, as it worked previously), the library does not work natively in the Cloudflare Workers environment. By saying natively, I mean without transpiling code or enabling Node.js compatibility modes or flags.
Hotfix solution
Currently, I found two possible solutions:
- Use browser version of
mimetext: import { createMimeMessage } from 'mimetext/browser';;
- Enable
node_compat = true in wrangler.toml to turn on Node.js polyfills.
Error details in cloudflare/wrangler-action
Node.js version: 18.19.0
NPM version: 10.2.3
