Skip to content

Fix dependency installation broken on Windows#16106

Merged
matthewp merged 1 commit into
mainfrom
create-astro-windows-cmd-spawn
Mar 26, 2026
Merged

Fix dependency installation broken on Windows#16106
matthewp merged 1 commit into
mainfrom
create-astro-windows-cmd-spawn

Conversation

@matthewp
Copy link
Copy Markdown
Contributor

Changes

  • Fixes npm create astro@latest failing to install dependencies on Windows since 5.0.1. The 5.0.1 change removed shell: true from spawn() to avoid DEP0190 warnings and attempted to handle Windows by appending .cmd to package manager names (e.g. npmnpm.cmd). However, .cmd files on Windows cannot be spawned directly without a shell — the Node.js docs explicitly state this. The fix now routes known package manager shims through cmd.exe /d /s /c <name>.cmd on Windows, which is the correct way to invoke them without shell: true.
  • Fixes the error [object Object] message that appeared when installation failed. The catch block was throwing a plain object { stdout, stderr, exitCode: 1 } instead of an Error, which stringified as [object Object] in the UI. It now throws a proper Error with the actual message.

Testing

  • All 116 existing create-astro tests pass. The Windows-specific spawn path is not unit-testable in CI (Linux/macOS), but the logic mirrors the approach documented in the Node.js child_process docs for invoking .cmd/.bat files without a shell.
  • Manually confirmed by the reporter that 5.0.0 worked and 5.0.1 did not — the root cause matches exactly: 5.0.1 introduced the broken .cmd direct-spawn approach.

Docs

No docs update needed — this is a bug fix in the CLI scaffolding tool with no user-facing API changes.

@changeset-bot
Copy link
Copy Markdown

changeset-bot Bot commented Mar 26, 2026

🦋 Changeset detected

Latest commit: e9af638

The changes in this PR will be included in the next version bump.

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR

@matthewp matthewp changed the title Dependency installation broken on Windows since create-astro 5.0.1 Fix dependency installation broken on Windows Mar 26, 2026
@matthewp matthewp added the pr preview Apply this label to a PR to generate a preview release label Mar 26, 2026
@github-actions github-actions Bot added pkg: create-astro Related to the `create-astro` package (scope) and removed pr preview Apply this label to a PR to generate a preview release labels Mar 26, 2026
@pkg-pr-new
Copy link
Copy Markdown

pkg-pr-new Bot commented Mar 26, 2026

npm i https://pkg.pr.new/create-astro@16106

commit: e9af638

@matthewp matthewp merged commit d241012 into main Mar 26, 2026
23 checks passed
@matthewp matthewp deleted the create-astro-windows-cmd-spawn branch March 26, 2026 20:17
This was referenced Mar 26, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

pkg: create-astro Related to the `create-astro` package (scope)

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants