Skip to content

Mono Repo Issue: pnpm installs all workspace projects even when a specific path is set #10941

@dwainbrowne

Description

@dwainbrowne

What versions & operating system are you using?

📝 Description

When deploying a Worker from a pnpm monorepo, Cloudflare always installs dependencies for all workspace projects (Scope: all 26 workspace projects) — even when a specific path is configured in the dashboard (e.g. /docs).

This results in Cloudflare installing unrelated projects before the actual build starts, often leading to failed builds when other workspaces use outdated or incompatible dependencies (e.g. node-sass@4.14.1 with Node 22).

This behavior happens before the build command executes, during Cloudflare’s environment initialization, and cannot be overridden using .cfignore or .cloudflare/project.toml.

Image

⚙️ Steps to Reproduce

  1. Create a monorepo using pnpm-workspace.yaml with multiple workspaces (e.g. apps/, api/, docs/).
  2. Add a Worker or Pages project inside /docs with its own package.json.
  3. Configure Cloudflare’s Git integration:
    • Build command: pnpm install && pnpm run build
    • Path: /docs
  4. Trigger a deploy.

🧾 Expected Behavior

Only the dependencies for the configured build path (/docs) should be installed.

✅ Example (expected):
Installing project dependencies: pnpm install --frozen-lockfile
Scope: 1 workspace project


❌ Actual Behavior

Cloudflare installs all workspace projects at the root level before running the build command.

Observed log:
Installing project dependencies: pnpm install --frozen-lockfile
Scope: all 26 workspace projects

This causes unrelated workspaces (such as older Nuxt 2 apps) to break deployment with dependency error

node-sass install: HTTP error 404 Not Found
node-sass postinstall: Build failed with error code: 1
Failed: error occurred while installing tools or dependencies


🧠 Impact

  • Greatly increases build time (installs every package in the monorepo).
  • Causes builds to fail if unrelated projects have incompatible dependencies.
  • Prevents isolated monorepo project deployments from working correctly with Cloudflare’s automatic builder.

💻 Environment

Setting Value
Cloudflare Workers (Build + Git Integration)
pnpm 8.15.0
Node 22.16.0
Build Path /docs
Build Command pnpm install && pnpm run build
Detected Workspaces 26

✅ Suggested Fix

  • Respect the configured Path for dependency installation.
  • Skip workspace-wide installation when .cfignore or .cloudflare/project.toml restricts the build context.
  • Optionally provide a setting to disable automatic root-level installs for monorepos.

Summary:
This issue makes Cloudflare unusable for pnpm-based monorepos when unrelated workspaces contain incompatible dependencies. The build system should respect the deployment path and isolate dependency installation accordingly.

Please provide a link to a minimal reproduction

No response

Describe the Bug


📄 Logs (Excerpt)

2025-10-10T08:28:32.288Z Installing project dependencies: pnpm install --frozen-lockfile
2025-10-10T08:28:36.896Z Scope: all 26 workspace projects
2025-10-10T08:30:27.059Z ELIFECYCLE Command failed with exit code 1.
2025-10-10T08:30:27.171Z Failed: error occurred while installing tools or dependencies

Please provide any relevant error logs

04:28:16.682 Initializing build environment...
04:28:22.589 Success: Finished initializing build environment
04:28:23.508 Cloning repository...
04:28:31.219 Detected the following tools from environment: pnpm@8.15.0, nodejs@22.16.0
04:28:32.288 Installing project dependencies: pnpm install --frozen-lockfile
04:28:36.896 Scope: all 26 workspace projects
04:28:37.169 .. | Progress: resolved 1, reused 0, downloaded 0, added 0
04:28:37.420 .. | +3762 ++++++++++++++++++++++++++++
04:28:38.172 .. | Progress: resolved 3762, reused 0, downloaded 26, added 23
04:28:39.171 .. | Progress: resolved 3762, reused 0, downloaded 175, added 175

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No fields configured for Bug.

    Projects

    Status

    Done

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions