When import this `import consumers from 'stream/consumers'`, miniflare complains: ```ts ✘ [ERROR] Co

When import this import consumers from 'stream/consumers', miniflare complains:
✘ [ERROR] Could not resolve "stream/consumers"

    src/routes/headlines.ts:13:22:
      13 │ import consumers from 'stream/consumers'
         ╵                       ~~~~~~~~~~~~~~~~~~

  The package "stream/consumers" wasn't found on the file system but is built into node. Are you trying to bundle for node? You can use "platform: 'node'" to do that, which will remove this error.

BUT: This page says that both the Buffer and Streams API are supported, and I have set node_compat = true in my wrangler.toml.
So why doesn't it work? :)

(Same error if I try import consumers from 'node:stream/consumers' instead btw.)
Do I also have to set compatibility_flags = [ "nodejs_compat" ] in addition to node_compat = true?
Cloudflare Docs
Implemented Node.js runtime APIs and enablement instructions for your Worker project.
Was this page helpful?