Skip to content

[docs] Fix pnpm and Bun runtime support for PublishAsNpmScript#1020

Open
aspire-repo-bot[bot] wants to merge 1 commit into
release/13.4from
docs/fix-pnpm-npm-script-17178-7449f5565e165861
Open

[docs] Fix pnpm and Bun runtime support for PublishAsNpmScript#1020
aspire-repo-bot[bot] wants to merge 1 commit into
release/13.4from
docs/fix-pnpm-npm-script-17178-7449f5565e165861

Conversation

@aspire-repo-bot
Copy link
Copy Markdown
Contributor

Documents changes from microsoft/aspire#17178 by @davidfowl.

Targeting release/13.4 based on the source PR milestone 13.4.

Why this PR is needed

PR microsoft/aspire#17178 fixed a bug where apps using .WithPnpm().PublishAsNpmScript() would fail at container startup with exit code 127 because pnpm was not available in the final node:alpine runtime image. The fix enables pnpm via Corepack in the runtime stage, and Bun apps now reuse the Bun build image for the runtime stage.

The existing Deploy JavaScript apps page covers PublishAsNpmScript but did not document how pnpm or Bun are handled in the runtime image, leaving users without guidance on the correct pattern.

What was changed

  • Updated src/frontend/src/content/docs/deployment/javascript-apps.mdx to add a "pnpm and Bun with PublishAsNpmScript" subsection after the existing package-script server examples. The section:
    • Explains that pnpm requires Corepack to be enabled in the runtime stage (and what happens without it)
    • Explains that Bun reuses the Bun build image for the runtime stage
    • Shows a C# code example using .WithPnpm().PublishAsNpmScript("start")
    • Shows the relevant generated Dockerfile lines (corepack enable pnpm && pnpm --version and the ENTRYPOINT)

Files modified

  • src/frontend/src/content/docs/deployment/javascript-apps.mdx (updated)

Generated by PR Documentation Check for issue #17178 · ● 59.2M ·

Documents microsoft/aspire#17178 which fixes the pnpm PublishAsNpmScript
Docker runtime. The generated runtime Dockerfile now enables pnpm via
Corepack before running the entrypoint, and Bun reuses the Bun build image
for the runtime stage.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
@aspire-repo-bot aspire-repo-bot Bot added the docs-from-code Copilot initiated issue from dotnet/aspire repo label May 20, 2026
@aspire-repo-bot aspire-repo-bot Bot requested a review from JamesNK May 20, 2026 04:10
@IEvangelist IEvangelist marked this pull request as ready for review May 20, 2026 04:17
@IEvangelist IEvangelist self-requested a review as a code owner May 20, 2026 04:17
Copilot AI review requested due to automatic review settings May 20, 2026 04:17
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Updates the “Deploy JavaScript apps” documentation to explain how PublishAsNpmScript handles pnpm and Bun at container runtime, aligning guidance with the behavior introduced in microsoft/aspire#17178.

Changes:

  • Added a new “pnpm and Bun with PublishAsNpmScript” subsection describing runtime-image behavior for pnpm (Corepack) and Bun (runtime image reuse).
  • Added a C# AppHost example using .WithPnpm().PublishAsNpmScript("start").
  • Included an excerpt of the relevant generated Dockerfile lines for the pnpm case.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment on lines +497 to +510
```csharp title="AppHost.cs — pnpm npm-script publish"
#pragma warning disable ASPIREJAVASCRIPT001

var builder = DistributedApplication.CreateBuilder(args);
builder.AddDockerComposeEnvironment("compose");

var frontend = builder
.AddJavaScriptApp("frontend", "../NodeFrontend")
.WithPnpm()
.PublishAsNpmScript("start")
.WithExternalHttpEndpoints();

builder.Build().Run();
```

`PublishAsNpmScript` works with pnpm and Bun in addition to npm and Yarn. The generated runtime Dockerfile stage is tailored to the package manager:

- **pnpm**: The runtime stage runs `corepack enable pnpm && pnpm --version` before the entrypoint, so pnpm is available when the start script executes. Without this step, the container fails at startup with exit code 127 because pnpm is not included in the base `node:alpine` image.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

docs-from-code Copilot initiated issue from dotnet/aspire repo

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant