Help with miniflare CLI on mac

Hi, I have installed miniflare globally on my mac but it keeps saying “command not found”. It has become a real pain as it is preventing me from deploying the cloudflare worker or even testing it on a dev server. To give some context, I am fighting against the following error.

“Uncaught Error: Some functionality, such as asynchronous I/O, timeouts, and generating random values, can only be performed while handling a request.”

From what I have learnt, I need to set --global-async-io, --global-timers, and --global-random to true. But again, I can’t. Because hey, “command not found.”

Also, if there is any way to set them to true without using the CLI, please let me know.

I understand this might be a silly question. Please humor me, I am very new to coding and development. Any help is greatly appreciated.

Thanks!

Hey,

You may have installed Miniflare v3 which no longer has a CLI (it’s been tightly integrated into Wrangler for a while now)

You can install v2 with npm install -g miniflare@2 and use that
Or you can switch to using Wrangler (Commands · Cloudflare Workers docs)

3 Likes

Miniflare version 3 no longer offers a CLI. You will want to migrate to wrangler 3, or use miniflare 2 with npm install -g miniflare@2.

Unfortunately, the release of wrangler 3 hasn’t gone that smoothly and DX is still suffering, so I would recommend sticking with Miniflare 2 or wrangler 2 for a little while longer.

3 Likes

Thank you both @WalshyMVP and @cherryjimbo. Installing miniflare@2 worked like a charm.

I would also like to mention an article that helped me overcome the problem in a slightly roundabout but simple way. It helped me go to sleep yesterday. Perhaps it will help someone else get some clarity over what’s happening.

https://dev.to/kleeut/cloudflare-workers-some-functionality-can-only-be-performed-while-handling-a-request-3bne

(Note - Following the article allowed my local server to start via “wrangler dev…” but miniflare was still not working. Before that wrangler would show a miniflare error and not even start the server.)

Thank you again!

This topic was automatically closed 3 days after the last reply. New replies are no longer allowed.