Skip to content

CLI: TypeScript AppHost hardcodes npm install, ignoring packageManager field #16121

Open

Description

Description

The Aspire CLI hardcodes npm install as the dependency installation command for TypeScript AppHosts (TypeScriptLanguageSupport.GetRuntimeSpec()), ignoring the packageManager field in the project's package.json.

This causes failures in yarn/pnpm monorepos where:

  1. npm install can take 60+ seconds in large monorepos, exceeding the AppHost startup timeout
  2. npm install fails with Invalid Version: errors when run against a yarn-managed node_modules directory
  3. Even with --no-build, the CLI still runs npm install

Reproduction

  1. Run aspire init in a yarn monorepo with "packageManager": "yarn@1.22.22" in package.json
  2. Run aspire start
  3. Observe the CLI runs npm.CMD install instead of yarn install

From the logs:
[GuestAppHostProject] Executing: C:\Program Files\nodejs\npm.CMD install [AppHost] npm error Invalid Version: [GuestAppHostProject] TypeScript (Node.js) apphost exited with code 1

Root Cause

TypeScriptLanguageSupport.GetRuntimeSpec() in src/Aspire.Hosting.CodeGeneration.TypeScript/TypeScriptLanguageSupport.cs:249-253:

csharp InstallDependencies = new CommandSpec { Command = "npm", Args = ["install"] },

This is unconditionally npm with no detection of the project's package manager.

Expected Behavior

The CLI should detect the project's package manager from:

  1. packageManager field in package.json (npm/yarn/pnpm)
  2. Lock file presence (yarn.lock → yarn, pnpm-lock.yaml → pnpm, package-lock.json → npm)

And use the detected package manager for the InstallDependencies command.

Workaround

Manually install tsx via the project's package manager before running aspire start --no-build:
�ash yarn add -W -D tsx aspire start --no-build

Additional Context

Discovered during an aspire init session against the excalidraw monorepo. Session export: https://gist.github.com/maddymontaquila/98b78fbd39bba0c499ac723bda9bb8b8

Activity

  1. added this to the Backlog milestone on Aug 6, 2026
  2. adamint commented on Aug 10, 2026

    @adamint
    Member

    I tried to repro this on macOS arm64 with Node 24.3.0 / npm 11.4.2 / Corepack 0.34.7, using PATH wrappers for npm, yarn, and pnpm so I could see the exact executable invoked.

    I can't reproduce the hardcoded npm install behavior on either 13.4.6 (13.4.6+87fe259e) or current main (13.6.0-dev, 9b79ab5):

    • With the reported packageManager: "yarn@1.22.22" + yarn.lock shape, both CLIs fail before install with Yarn Classic is not supported for TypeScript AppHosts...; no package-manager process was invoked.
    • With a pnpm monorepo (packageManager: "pnpm@10.30.1" + pnpm-lock.yaml), both CLIs invoked pnpm install --ignore-workspace. --no-build still invokes install, but it was still pnpm, not npm.
    • With supported Yarn (packageManager: "yarn@4.9.2" + yarn.lock, and aspire-apphost included in the workspaces list), both CLIs invoked yarn install.

    Lockfile/module behavior also matched the selected toolchain in my repros: pnpm used aspire-apphost/pnpm-lock.yaml + node_modules, Yarn 4 used .pnp.cjs / .yarn + yarn.lock, and I didn't see a package-lock.json get created.

    So I think the hardcoded-npm install part is no longer reproing in current stable/main. The Yarn Classic case still doesn't work, but it now fails as unsupported instead of falling through to npm.

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

    Type

    No type

    Projects

    No projects

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions