lauragift21 / staff-directory

an intuitive resource hub designed to showcase the teams within an organization.
https://staff-directory-4to.pages.dev/
18 stars 8 forks source link

D1 bindings require module-format workers. [code: 10021] #2

Open MilleVenti opened 3 months ago

MilleVenti commented 3 months ago

Hi, I'm trying to deploy this project , following this tutorial too: https://developers.cloudflare.com/d1/tutorials/build-a-staff-directory-app/

Locally works fine, but when I try to deploy it I get the following error:

D1 bindings require module-format workers. [code: 10021]

On wrangler.toml I had to put the following entry point main = "./app/routes/index.tsx"

I cannot see any addEventListener, but only export default in the code, so according to me the worker is already in module-format.

Furthermore in package.json there is: "type": "module",

wrangler 3.50.0 npm 10.5.0 node v20.12.2 Windows 10

Thank you

lauragift21 commented 3 months ago

Hello @MilleVenti! Could you confirm you have the following in your wrangler.toml file https://github.com/lauragift21/staff-directory/blob/main/wrangler.example.toml

You don't need to specify a main entry point; once you deploy your application, you must ensure that the D1 binding is passed in the dashboard. Let me know if this helps.

MilleVenti commented 3 months ago

I had to specify an entry point because the starting issue happens trying to deploy via 'npx wrangler deploy', since I get the following error: X [ERROR] Missing entry-point: The entry-point should be specified via the command line (e.g. wrangler deploy path/to/script) or the main config field.

And even if I put 'app/routes/index.tsx' as entry point in the command line I get the same error:

D1 bindings require module-format workers. [code: 10021]

Now I add pages_build_output_dir = "./dist", instead of main = "./app/routes/index.tsx"

This is my wrangler.toml

name = "staff-directory" pages_build_output_dir = "./dist" compatibility_date = "2023-12-01"

[[r2_buckets]] binding = "MY_BUCKET" bucket_name = "employee-avatars"

[[d1_databases]] binding = "DB" database_name = "staff-directory" database_id = "a1d2b173-9510-4ca6-b4e1-5f7f0413db04"

But I get the same code [code: 10021]. So which or how entry point I have to set to avoid entry point error and code 10021 error with the command 'npx wrangler deploy'?