Skip to content

fix(package-env): improve Windows npm version detection#983

Merged
John-David Dalton (jdalton) merged 3 commits intov1.xfrom
fix/windows
Dec 22, 2025
Merged

fix(package-env): improve Windows npm version detection#983
John-David Dalton (jdalton) merged 3 commits intov1.xfrom
fix/windows

Conversation

@billxinli
Copy link
Copy Markdown

@billxinli Bill Li (billxinli) commented Dec 17, 2025

Attempting to fix a bug where Socket CLI fails to detect npm version (socket optimize blocked) on windows.

Windows 11 + Powershell

Screenshot 2025-12-16 202932

Windows 11 + cmd

Screenshot 2025-12-16 202729

OSX

Screenshot 2025-12-17 at 1 43 20 AM

Note

Strengthens npm version detection on Windows to handle shims and JS entrypoints reliably.

  • Add preferWindowsCmdShim to select .cmd shims and use when resolving npm path
  • Use resolveBinPathSync in getAgentVersion to detect JS entrypoints (.js/.cjs/.mjs) and execute via node; otherwise spawn directly with shell: WIN32
  • Update getAgentExecPath for npm to prefer .cmd next to node.exe and handle shim replacement
  • Add test/package-environment.npm-version.test.mts with Vitest cases for JS entrypoint execution, fallback on resolution failure, and non-JS executables

Written by Cursor Bugbot for commit d245ebd. Configure here.

@billxinli Bill Li (billxinli) marked this pull request as ready for review December 17, 2025 17:33
Comment thread src/utils/package-environment.mts
Comment thread src/utils/package-environment.mts
Comment thread test/package-environment.npm-version.test.mts Outdated
Comment thread test/package-environment.npm-version.test.mts
@jdalton
Copy link
Copy Markdown
Contributor

Cursor (@cursor) review

Copy link
Copy Markdown

@cursor cursor bot left a comment

Choose a reason for hiding this comment

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

✅ Bugbot reviewed your changes and found no bugs!


Comment @cursor review or bugbot run to trigger another review on this PR

@jdalton John-David Dalton (jdalton) merged commit 1de47a9 into v1.x Dec 22, 2025
8 checks passed
@jdalton John-David Dalton (jdalton) deleted the fix/windows branch December 22, 2025 19:58
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.

3 participants