Trying to use D1 for my project. But getting an error

Hello everyone. I am new to cloudflare stuff and started experimenting with workers. Im trying to publish a Pastebin like app so I can store pastes in it and share those. https://gist.github.com/frontlineroleplaysrilanka/7e8e8f39e214f49603f2407693b25caa Here is the current code of index.js and im trying to utilize the D1 database in it. But when I try to deploy it, an error comes which shows:
X [ERROR] A request to the Cloudflare API (/accounts/xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx/workers/scripts/paste) failed.

D1 bindings require module-format workers. [code: 10021]
X [ERROR] A request to the Cloudflare API (/accounts/xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx/workers/scripts/paste) failed.

D1 bindings require module-format workers. [code: 10021]
Any help please ๐Ÿ˜Š ? Thanks.
Gist
Paste App but using D1
Paste App but using D1. GitHub Gist: instantly share code, notes, and snippets.
3 Replies
Hard@Work
Hard@Workโ€ข6mo ago
Cloudflare Docs
Migrate from Service Workers to ES Modules ยท Cloudflare Workers docs
Write your Worker code in ES modules syntax for an optimized experience.
Heshini Shehara
Heshini SheharaOPโ€ข6mo ago
Just started experimenting. Ill try to understand this. Thanks for the help โค๏ธ ๐Ÿ™‚ Fixed everything. Thanks again and really appreciate your support. โค๏ธ
Hard@Work
Hard@Workโ€ข6mo ago
Happy to help!
Want results from more Discord servers?
Add your server