Skip to content

fix(vscode): use shell mode for spawn on Windows to detect npm correctly - #653

Merged
lizhengfeng101 merged 1 commit into
alibaba:mainfrom
aalhadxx:fix/vscode-shell-clean
Aug 1, 2026
Merged

fix(vscode): use shell mode for spawn on Windows to detect npm correctly#653
lizhengfeng101 merged 1 commit into
alibaba:mainfrom
aalhadxx:fix/vscode-shell-clean

Conversation

@aalhadxx

Copy link
Copy Markdown
Contributor

Fixes #453

Problem

On Windows, child_process.spawn cannot find npm.cmd / npx.cmd without shell: true, causing the VS Code extension to falsely report npm not detected and disable CLI features.

Fix

probeCommand now hardcodes --version and adds shell: true only on win32. runRaw is intentionally left unchanged — it receives user-controlled args and must not use shell: true for security.

Tests

  • CliService.isAvailable — verifies node is found on Windows
  • CliService probe shell option — asserts shell: true on win32 and shell: false on Linux/macOS
  • Existing runRaw and testConnection tests remain unaffected (use real spawn)

Supersedes #584 and #626.

On Windows, child_process.spawn cannot find npm.cmd / npx.cmd without
shell: true, causing the VS Code extension to falsely report 'npm not
detected' and disable CLI features.

probeCommand now hardcodes ['--version'] and adds shell: true only on
win32. runRaw is intentionally left unchanged — it receives user-controlled
args and must not use shell: true for security.

Fixes alibaba#453
@github-actions

Copy link
Copy Markdown
Contributor

OpenCodeReview: No comments generated. Looks good to me.

@lizhengfeng101 lizhengfeng101 left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

LGTM

@lizhengfeng101
lizhengfeng101 merged commit f29659b into alibaba:main Aug 1, 2026
9 checks passed
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.

Windows 环境下vs code插件检测误报"未检测到 npm"(spawn 未使用 shell 模式)

2 participants