Skip to content

fix(build): find npm when only npm.exe exists on Windows - #31

Merged
cderv merged 2 commits into
cscheid:mainfrom
cderv:fix/npm-exe-on-windows
Dec 2, 2026
Merged

cderv merged 2 commits into
cscheid:mainfrom
cderv:fix/npm-exe-on-windows

Conversation

@cderv

@cderv cderv commented Dec 2, 2026

Copy link
Copy Markdown
Collaborator

On Windows, cargo build fails in build.rs with "program not found" when the Node install has no npm.cmd. I hit it with nvm v2, which only ships npm.exe. cargo xtask ci fails the same way at its UI test step, and cargo xtask housekeeping skips its npm checks with "needs Node.js / npm". SKIP_UI_BUILD=1 only gets past build.rs.

build.rs, the xtask UI commands and the housekeeping npm checks all hardcoded npm.cmd on Windows. They now use npm.cmd when a directory on PATH has it, and plain npm otherwise, which finds npm.exe. Installs with the .cmd shim keep the same behavior.

build.rs cannot share code with xtask, so the small lookup is in both. housekeeping.rs reuses the xtask one.

Test Plan

  • cargo build -p braid without SKIP_UI_BUILD on a machine with only npm.exe: npm ci and the vite build ran and the build finished
  • CI on Windows, Linux and macOS (the npm.cmd path and non-Windows)

The xtask copy was not run on an npm.exe-only install. It is the same code as build.rs.

cderv added 2 commits December 2, 2026 16:44
On Windows, build.rs and cargo xtask always spawned `npm.cmd`. A Node
install without that shim, like the nvm v2 one on a contributor machine
that ships only `npm.exe`, failed with "program not found": `cargo build`
stopped in build.rs, and `cargo xtask ci` stopped at its UI test step.
SKIP_UI_BUILD=1 got past build.rs only.

Use `npm.cmd` when a directory on PATH has it, and plain `npm` otherwise
(which resolves to `npm.exe`). Installs that ship the `.cmd` shim, as on
GitHub's Windows runners (unverified), keep the same behavior.

build.rs cannot share code with xtask, so the small lookup exists in both;
housekeeping.rs reuses the xtask one.

Verified on the affected machine: `cargo build -p braid` without
SKIP_UI_BUILD reran `npm ci` and the vite build and finished. The xtask
copy was not run with an npm.exe-only install.
@cderv
cderv merged commit c0f7f24 into cscheid:main Dec 2, 2026
4 checks passed
@cderv cderv mentioned this pull request Dec 2, 2026
1 of 2 tasks
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.

1 participant