Skip to content

cf workers … API commands fail without workerd: workers module statically imports miniflare #390

Closed

Description

@gatezh

Summary

cf workers scripts list and cf workers scripts search are Cloudflare API reads, but they fail when the platform workerd package isn't installed. Other API command groups, such as cf turnstile widgets list, work in the same shell. The workers command module statically imports a chunk that imports miniflare at the top level, and loading miniflare requires workerd.

Reproduction

cf 1.0.0-beta.18, Node 24, linux-arm64. It's a global npm install -g cf with the @cloudflare/workerd-linux-* package removed. That's how we keep a devcontainer image small: we ship cf for API work, and projects that need the local runtime get it from their own cf dev dependency.

mkdir /tmp/cf-repro && cd /tmp/cf-repro   # no package.json, no config
export CLOUDFLARE_ACCOUNT_ID=<id> CLOUDFLARE_API_TOKEN=<token>

cf turnstile widgets list   # makes the API call
cf workers scripts list     # fails before any request
┌ Error
│ The package "@cloudflare/workerd-linux-arm64" could not be found, and is
│ needed by workerd.
└

Cause

In the published dist/:

  • workers-pP5tsDbD.mjs statically imports containers-BtcOgwm5.mjs.
  • containers-BtcOgwm5.mjs has import { getFreshSourceMapSupport, getNodeCompat } from "miniflare".
  • miniflare loads workerd at import time.

local-runtime-*.mjs is already loaded with a dynamic import(), and the turnstile module has no static path to miniflare.

Suggested fix

Load miniflare lazily in the containers code: a dynamic import("miniflare") where getFreshSourceMapSupport and getNodeCompat are used, as local-runtime already does. API-only subcommands would then not need workerd.

Activity

  1. petebacondarwin commented on Nov 4, 2026

    @petebacondarwin
    Collaborator

    Fixed via cloudflare/workers-sdk#16623
    Will be released in 1.0.0-beta.28

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions