Skip to content

Conversation

@billxinli
Copy link

@billxinli 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

Improve npm version detection on Windows by resolving shims/JS entrypoints and add targeted tests.

  • Package environment detection (src/utils/package-environment.mts)
    • Prefer Windows .cmd shim for npm when paths are absolute and extensionless.
    • Resolve executable with resolveBinPathSync; if it’s a JS file (.js/.cjs/.mjs), run via Node with --version; otherwise spawn directly (with shell on Windows).
    • Additional checks for npm alongside node and fallback to whichBin retained.
  • Tests (test/package-environment.npm-version.test.mts)
    • Add unit tests covering JS entrypoint execution via Node, fallback when resolution fails, and direct spawn for non-JS executables.

Written by Cursor Bugbot for commit b266e3f. Configure here.

@billxinli billxinli marked this pull request as ready for review December 17, 2025 17:33
const quotedCmd = `\`${agent} ${FLAG_VERSION}\``
debugFn('stdio', `spawn: ${quotedCmd}`)
try {
let stdout: string
Copy link
Collaborator

Choose a reason for hiding this comment

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

should this be limited to windows?

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.

4 participants