Add installation validation with user notifications for JavaScript package managers
Description
Adds installation validation for Node.js and JavaScript package managers (npm, yarn, pnpm) following the same pattern from #12787 for Python/uv. When commands are missing, users see notifications with installation links rather than cryptic errors.
Shared Infrastructure
- Added
CoalescingAsyncOperation.csandRequiredCommandValidator.csreferences fromsrc/Shared/as internal shared source - Compiled into project via
<Compile Include="$(SharedDir)...">references
Validation Managers
Created four installation managers extending RequiredCommandValidator:
-
NodeInstallationManager- validatesnodecommand -
NpmInstallationManager- validatesnpmcommand -
YarnInstallationManager- validatesyarncommand -
PnpmInstallationManager- validatespnpmcommand
Each provides EnsureInstalledAsync(bool throwOnFailure = true) and help links to installation docs.
Integration Points
Service Registration:
-
NodeInstallationManagerin:AddNodeApp,AddJavaScriptApp,AddViteApp - Package manager validators in:
WithNpm,WithYarn,WithPnpm
Validation Hooks:
- Added
OnBeforeResourceStartedhook onJavaScriptInstallerResource - Node validation runs first (all package managers require Node)
- Package manager validation runs based on configured manager (npm/yarn/pnpm)
- Uses
throwOnFailure: falseto show notifications without altering natural error flow
Behavior
When a command is missing:
- Warning logged
- Notification shown via
IInteractionServicewith installation link - App continues startup and fails naturally with original error
- Existing error behavior preserved
Example notification:
Missing command: node
Required command 'node' was not found. See installation instructions for more details.
[Installation instructions] → https://nodejs.org/en/download/
Checklist
- Is this feature complete?
- [x] Yes. Ready to ship.
- [ ] No. Follow-up changes expected.
- Are you including unit tests for the changes and scenario tests if relevant?
- [x] Yes
- [ ] No
- Did you add public API?
- [ ] Yes
- [x] No
- Does the change make any security assumptions or guarantees?
- [ ] Yes
- [x] No
- Does the change require an update in our Aspire docs?
- [ ] Yes
- [x] No
Original prompt
Make the same change in https://github.com/dotnet/aspire/pull/12787 but for Aspire.Hosting.JavaScript. yarn, npm, pnpm and node.
✨ Let Copilot coding agent set things up for you — coding agent works faster and does higher quality work when set up for your repo.
🚀 Dogfood this PR with:
⚠️ WARNING: Do not do this without first carefully reviewing the code of this PR to satisfy yourself it is safe.
curl -fsSL https://raw.githubusercontent.com/dotnet/aspire/main/eng/scripts/get-aspire-cli-pr.sh | bash -s -- 12840
Or
- Run remotely in PowerShell:
iex "& { $(irm https://raw.githubusercontent.com/dotnet/aspire/main/eng/scripts/get-aspire-cli-pr.ps1) } 12840"