Skip to content

Conversation

Copy link
Contributor

Copilot AI commented Jun 4, 2025

The WithNpmPackageInstallation API was incorrectly requiring package-lock.json for all npm operations, including npm install which only needs package.json. This caused failures in common developer workflows where developers create a package.json file but haven't run npm install yet.

Problem

When using the default configuration:

var builder = DistributedApplication.CreateBuilder(args);

var api = builder.AddNpmApp("api", "../Api")
                 .WithNpmPackageInstallation(); // defaults to useCI: false

builder.Build().Run();

The application would fail with:

No package-lock.json file found in C:\Users...\Api

This occurred even when using npm install (not npm ci), which should work with just package.json.

Solution

Modified NodePackageInstaller.PerformInstall() to conditionally check for different files based on the install command:

  • When installCommand == "ci": checks for lockfile (package-lock.json) - preserves existing behavior
  • When installCommand == "install": checks for package.json - new behavior that fixes the issue

Key Benefits

npm install now works when only package.json exists (common developer workflow)
npm ci still requires package-lock.json (correct behavior)
✅ Error messages clearly indicate which file is missing based on the command
✅ No breaking changes to existing APIs
✅ Consistent with how npm actually works

Testing

Added comprehensive tests to validate both scenarios work correctly and error messages are appropriate.

Fixes #618.

Warning

Firewall rules blocked me from connecting to one or more addresses

I tried to connect to the following addresses, but was blocked by firewall rules:

  • dnceng.pkgs.visualstudio.com
    • Triggering command: dotnet build src/CommunityToolkit.Aspire.Hosting.NodeJS.Extensions/CommunityToolkit.Aspire.Hosting.NodeJS.Extensions.csproj (dns block)
    • Triggering command: dotnet build src/CommunityToolkit.Aspire.Hosting.NodeJS.Extensions/CommunityToolkit.Aspire.Hosting.NodeJS.Extensions.csproj -f net8.0 (dns block)
  • download.visualstudio.microsoft.com
    • Triggering command: wget REDACTED -O /tmp/dotnet-9.tar.gz (dns block)
  • http://168.63.129.16:80/machine/
    • Triggering command: /usr/bin/python3 -u bin/WALinuxAgent-2.13.1.1-py3.9.egg -collect-logs (http block)

If you need me to access, download, or install something from one of these locations, you can either:


💡 You can make Copilot smarter by setting up custom instructions, customizing its development environment and configuring Model Context Protocol (MCP) servers. Learn more Copilot coding agent tips in the docs.

Copilot AI and others added 3 commits June 4, 2025 01:13
Co-authored-by: aaronpowell <434140+aaronpowell@users.noreply.github.com>
Co-authored-by: aaronpowell <434140+aaronpowell@users.noreply.github.com>
Co-authored-by: aaronpowell <434140+aaronpowell@users.noreply.github.com>
Copilot AI changed the title [WIP] The WithNpmPackageInstallation API assumes that packages have already been installed Fix npm package installation to check appropriate files based on command Jun 4, 2025
Copilot AI requested a review from aaronpowell June 4, 2025 01:18
Copilot finished work on behalf of aaronpowell June 4, 2025 01:19
@aaronpowell aaronpowell marked this pull request as ready for review June 4, 2025 02:06
@github-actions
Copy link
Contributor

github-actions bot commented Jun 4, 2025

Code Coverage

Package Line Rate Branch Rate Complexity Health
CommunityToolkit.Aspire.EventStore 100% 100% 46
CommunityToolkit.Aspire.GoFeatureFlag 100% 97% 74
CommunityToolkit.Aspire.Hosting.ActiveMQ 80% 40% 100
CommunityToolkit.Aspire.Hosting.ActiveMQ.MassTransit 1% 0% 14
CommunityToolkit.Aspire.Hosting.Adminer 73% 50% 20
CommunityToolkit.Aspire.Hosting.Azure.Dapr 67% 50% 828
CommunityToolkit.Aspire.Hosting.Azure.Dapr.Redis 97% 88% 36
CommunityToolkit.Aspire.Hosting.Azure.DataApiBuilder 100% 100% 22
CommunityToolkit.Aspire.Hosting.Azure.StaticWebApps 84% 50% 28
CommunityToolkit.Aspire.Hosting.Bun 82% 71% 54
CommunityToolkit.Aspire.Hosting.Dapr 63% 51% 724
CommunityToolkit.Aspire.Hosting.DbGate 94% 50% 18
CommunityToolkit.Aspire.Hosting.Deno 84% 75% 72
CommunityToolkit.Aspire.Hosting.EventStore 94% 100% 18
CommunityToolkit.Aspire.Hosting.GoFeatureFlag 93% 50% 18
CommunityToolkit.Aspire.Hosting.Golang 94% 50% 16
CommunityToolkit.Aspire.Hosting.Java 69% 72% 120
CommunityToolkit.Aspire.Hosting.k6 58% 12% 20
CommunityToolkit.Aspire.Hosting.LavinMQ 78% 50% 18
CommunityToolkit.Aspire.Hosting.LavinMQ.MassTransit 1% 0% 14
CommunityToolkit.Aspire.Hosting.MailPit 91% 50% 14
CommunityToolkit.Aspire.Hosting.Meilisearch 73% 57% 50
CommunityToolkit.Aspire.Hosting.MongoDB.Extensions 96% 83% 36
CommunityToolkit.Aspire.Hosting.MySql.Extensions 100% 88% 76
CommunityToolkit.Aspire.Hosting.Ngrok 52% 35% 82
CommunityToolkit.Aspire.Hosting.NodeJS.Extensions 89% 68% 100
CommunityToolkit.Aspire.Hosting.Ollama 67% 70% 174
CommunityToolkit.Aspire.Hosting.PapercutSmtp 92% 50% 10
CommunityToolkit.Aspire.Hosting.PostgreSQL.Extensions 98% 88% 92
CommunityToolkit.Aspire.Hosting.Python.Extensions 68% 55% 90
CommunityToolkit.Aspire.Hosting.RavenDB 63% 49% 136
CommunityToolkit.Aspire.Hosting.Redis.Extensions 100% 80% 40
CommunityToolkit.Aspire.Hosting.Rust 94% 83% 16
CommunityToolkit.Aspire.Hosting.SqlDatabaseProjects 75% 62% 130
CommunityToolkit.Aspire.Hosting.Sqlite 97% 91% 54
CommunityToolkit.Aspire.Hosting.SqlServer.Extensions 100% 85% 76
CommunityToolkit.Aspire.MassTransit.RabbitMQ 100% 100% 30
CommunityToolkit.Aspire.Meilisearch 97% 92% 68
CommunityToolkit.Aspire.Microsoft.Data.Sqlite 37% 27% 194
CommunityToolkit.Aspire.Microsoft.EntityFrameworkCore.Sqlite 51% 50% 92
CommunityToolkit.Aspire.OllamaSharp 71% 64% 98
CommunityToolkit.Aspire.RavenDB.Client 60% 53% 237
Summary 71% (6544 / 9175) 58% (2035 / 3510) 4155

Minimum allowed line rate is 60%

@aaronpowell aaronpowell temporarily deployed to azure-artifacts June 4, 2025 05:59 — with GitHub Actions Inactive
@aaronpowell aaronpowell merged commit ebfd5be into main Jun 4, 2025
89 of 90 checks passed
@aaronpowell aaronpowell deleted the copilot/fix-618 branch June 4, 2025 06:22
@aaronpowell aaronpowell added this to the 9.6 milestone Jun 18, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

The WithNpmPackageInstallation API assumes that packages have already been installed

2 participants