Skip to content

Prevent the generation of a nested pnpm-workspace.yaml and local pnpm install when running create-void inside an existing monorepo #888

Open

Description

@yuikisaito

Describe the bug

When running create-void (or vp create void) targeting a subdirectory within an existing pnpm monorepo (e.g., apps/website), pnpm-workspace.yaml and pnpm-lock.yaml are generated directly under the target directory.

This creates an unwanted nested workspace within the monorepo, breaking consistency with the root pnpm-workspace.yaml, catalog settings, and the root lock file.

Steps to Reproduce

  1. Create and navigate into a pnpm monorepo environment (with a pnpm-workspace.yaml at the root):

    vp create vite:monorepo my-monorepo --no-interactive --package-manager pnpm
    cd my-monorepo
  2. Run create-void targeting a subdirectory within the monorepo (e.g., apps/website):

    # Example 1: Via vp
    vp create void apps/website -- --toolchain vite-plus --framework vue --starter sqlite --deploy none
    
    # Example 2: Running pnpm create void directly
    pnpm create void apps/website -- --toolchain vite-plus --framework vue --starter sqlite --deploy none
  3. Check the contents of the generated subdirectory (apps/website):

    ls -la apps/website/pnpm-workspace.yaml apps/website/pnpm-lock.yaml

Expected Behavior

  • If a pnpm-workspace.yaml already exists in a parent or ancestor directory (i.e., in a monorepo environment):
    • Do not create a new pnpm-workspace.yaml directly under the target directory.
    • If necessary, merge required settings (esbuild, sharp, workerd, etc.) into the allowBuilds field of the root pnpm-workspace.yaml, or prompt the user to approve them at the root level (pnpm approve-builds).
    • Do not run pnpm install specifically for the target directory to generate an individual pnpm-lock.yaml (delegate the full installation to the root-level package manager or wrapper tool, or allow it to be suppressed with a --no-install flag).

Actual Behavior

  • Regardless of whether the parent directory is a monorepo, apps/website/pnpm-workspace.yaml is created unconditionally.
  • Immediately afterward, pnpm install --no-frozen-lockfile is executed with the target directory as the current working directory, causing pnpm to recognize the target directory itself as an independent workspace root and generating apps/website/pnpm-lock.yaml.
  • As a result, an invalid nested workspace remains within the monorepo structure.

Root Cause Analysis

This is caused by the following processes running unconditionally in packages/create-void:

  1. Forced writing via writePnpmBuildPolicy:

    • Relevant code:
      packages/create-void/src/pm.ts#L10-L20
    • A new pnpm-workspace.yaml is unconditionally created directly under the target directory without checking whether a pnpm-workspace.yaml already exists in any parent or ancestor directories of the target.
  2. Executing installation directly under the target:

    • Relevant code:
      packages/create-void/src/main.ts#L62-L76
    • run(pmInstall(pm), targetDir) (pnpm install --no-frozen-lockfile) is executed with cwd set to the target directory where pnpm-workspace.yaml was just created. Consequently, pnpm treats it as an independent workspace root and generates a separate pnpm-lock.yaml inside the subdirectory.
    • Additionally, create-void lacks a --no-install option for external tools or monorepos.

Proposed Solutions

  1. Workspace detection in ancestor directories:

    • Before executing writePnpmBuildPolicy, traverse upward from the target directory through parent directories to check for an existing pnpm-workspace.yaml (workspace root).
    • If an existing monorepo root is found:
      • Skip outputting pnpm-workspace.yaml to the subdirectory.
      • Append/merge the configuration into the allowBuilds field of the root pnpm-workspace.yaml, or prompt execution at the root level.
  2. Adding a --no-install option:

    • Support a --no-install (or --skip-install) flag to skip automatic dependency installation, similar to other create-* packages such as @tanstack/cli and sv.

Activity

  1. yuikisaito commented on Nov 20, 2026

    @yuikisaito
    Author

    I'd be happy to submit a PR for this if the proposed approach looks good to you! Please let me know.

  2. cpojer commented on Nov 21, 2026

    @cpojer
    Member

    Yes, please send a PR!

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

    Fields

    Priority

    None yet

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions