CLI: TypeScript AppHost hardcodes npm install, ignoring packageManager field
- Dominant language
- C#
- Stars
- 6.3k
- Forks
- 991
- Avg merge
- 2d 15h
- Merged PRs (30d)
- 196
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](https://github.com/excalidraw/excalidraw) monorepo. Session export: https://gist.github.com/maddymontaquila/98b78fbd39bba0c499ac723bda9bb8b8
Contributor guide
Assessment
This issue has not been assessed yet.