skymethod / denoflare

Develop, test, and deploy Cloudflare Workers with Deno.
https://denoflare.dev
MIT License
699 stars 33 forks source link

Error Deploying Deno Script to Cloudflare Workers Using Denoflare: Unexpected Argument 'main.ts' During Bundling #79

Open jacksonkasi0 opened 5 hours ago

jacksonkasi0 commented 5 hours ago

I am experiencing an issue when attempting to deploy my Deno script to Cloudflare Workers using Denoflare. While the denoflare serve main.ts command functions correctly, allowing me to test the script locally, the denoflare push main.ts command fails during the bundling process. The error message received is: image

TS0: error: unexpected argument 'main.ts' found

Steps to Reproduce:

Check out the code to reproduce: https://github.com/jacksonkasi0/NexLayer/blob/master/server/deno.json

  1. Run denoflare serve main.ts to serve the script locally—this works as expected.
  2. Run denoflare push main.ts to deploy the script to Cloudflare Workers—this results in the aforementioned error.

Additional Information:

I have attempted to update Denoflare to the latest version and downgraded Deno to version 1.25.4, but the issue persists. Any guidance on resolving this deployment error would be greatly appreciated.

johnspurlock-skymethod commented 5 hours ago

Try using a fully qualified path to your main.ts as the arg.

Also: you'll need to use deno 1.x, still working on getting denoflare working on deno2, which breaks a bunch of the ways denoflare works under the hood

jacksonkasi0 commented 5 hours ago

@johnspurlock-skymethod Thank you for the guidance. I’ve switched to Deno 1.34.3 and tried using the fully qualified path to main.ts. However, I’m now encountering a different issue when running denoflare push main:

error: Uncaught (in promise) Error: putScript failed: status=403, errors=10000 Authentication error

I've double-checked my .denoflare config, and both the accountId and apiToken are set as specified. The token has the required permissions for editing Cloudflare Workers. Could this be related to any specific configuration, or are there additional authentication steps I might have missed?

Any insights would be greatly appreciated!

johnspurlock-skymethod commented 5 hours ago

Hmm, try passing the accountId and apiToken via the command line (--account-id and --api-token, see https://denoflare.dev/cli/push) to isolate out any config issue first.

Can also throw a --verbose on there too for more clues. Yes make sure that api token has edit workers permission.

jacksonkasi0 commented 5 hours ago

Thank you for the suggestions. I tried passing the accountId and apiToken directly through the command line, along with the --verbose flag for more information.

Here’s what I did:

denoflare push D:/JACKWORKS/NexLayer/server/main.ts --account-id 06e6f7xxxxxxb2c5daf2 --api-token 1fY-JrvgZi_xxxxx--Z7T3WJS --verbose 

However, I’m still getting a 403 Authentication error with the message:

success: false,
errors: [ { code: 10000, message: "Authentication error" } ]

I confirmed that the API token has the Edit Cloudflare Workers permission, and the accountId matches what is listed in my Cloudflare dashboard.

Could there be another setting or permission I’m missing, or is there a limitation specific to Denoflare with this API token configuration?

jacksonkasi0 commented 5 hours ago

Hey @johnspurlock-skymethod, sorry about that – I realized I had an error in the account ID, which caused the issue. Thanks for your help; it's working now! 🙂

johnspurlock-skymethod commented 5 hours ago

ah great - sorry about the 1.x requirement at the moment, actually working on adapting denoflare for deno2 as we speak, but want to be very careful not to break any of the 1.x folks (like me) in production

jacksonkasi0 commented 5 hours ago

No problem at all! Thank you for the update, and I appreciate your careful approach to supporting both Deno 1.x and 2.x users. I’ll stick with 1.x for now and look forward to trying it out on Deno 2 once it's ready. Thanks for all the hard work you're putting into Denoflare!