Repository navigation
fix(cli): detect nvm-windows global installs in update notices - #1801
Conversation
mldangelo-oai
left a comment
There was a problem hiding this comment.
Thanks for identifying the missing -g. I reproduced it and checked the install layout against npm's documentation and configuration implementation. The issue is real: the suggested local install does not update the global CLI.
I replaced the directory-name regex with a comparison against the node_modules directory beside the resolved Windows Node executable. This also handles configurable nvm roots, using the existing path API and no subprocess or new setting. The existing table now covers default/custom roots, local installs, and npx/standalone precedence. A directory-link regression also verifies the nvm launch layout; resolving the executable path keeps it consistent with the CLI module path.
The regression fails with the original patch and passes with the revised detection. Focused tests, type checks, and formatting passed. I corrected the PR description to distinguish those fixtures from a manual Windows installation, which I did not perform.
Summary
Windows npm packages installed alongside Node, including nvm-windows installations, receive an update notice without
-g. Running the suggested command installs a local package instead of updating the global CLI.Changes
Recognize the
node_modulesdirectory beside the resolved Windows Node executable. This follows npm's global installation layout and handles custom nvm installation roots without depending on a directory namednvmor a version-string pattern.Extend the existing command-selection table for default and custom Windows roots, mixed path separators and casing, local project installs, and the existing npx and standalone-release precedence. A real directory-link fixture verifies that the default executable path resolves to the same installation as the CLI module.
Testing
-gfor a custom nvm root with the original patch, then passed the focused update-notice suite with the revised detection.native/prebuilt/COPYRIGHT-library.html). Full platform coverage remains with CI.Risk and rollout
Changes only the printed update command. The new detection applies to Windows; existing package-manager selection and local-install behavior are preserved. No new public commands, flags, environment variables, or dependencies.
Public disclosure review