Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
MilleVenti opened this issue Apr 14, 2024 · 2 comments
Open

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

MilleVenti opened this issue Apr 14, 2024 · 2 comments

Comments

@MilleVenti
Copy link

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
Copy link
Owner

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
Copy link
Author

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'?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants