diff --git a/extensions/npm/src/features/packageJSONContribution.ts b/extensions/npm/src/features/packageJSONContribution.ts index f0032be8316cc..999f39664f1c2 100644 --- a/extensions/npm/src/features/packageJSONContribution.ts +++ b/extensions/npm/src/features/packageJSONContribution.ts @@ -293,7 +293,13 @@ export class PackageJSONContribution implements IJSONContribution { // COREPACK_ENABLE_PROJECT_SPEC makes the npm view command succeed // even if packageManager specified a package manager other than npm. const env = { ...process.env, COREPACK_ENABLE_AUTO_PIN: '0', COREPACK_ENABLE_PROJECT_SPEC: '0' }; - cp.execFile(`"${npmCommandPath}"`, args, { cwd, env, shell: true }, (error, stdout) => { + let options: cp.ExecFileOptions = { cwd, env }; + let commandPath: string = npmCommandPath; + if (process.platform === 'win32') { + options = { cwd, env, shell: true }; + commandPath = `"${npmCommandPath}"`; + } + cp.execFile(commandPath, args, options, (error, stdout) => { if (!error) { try { const content = JSON.parse(stdout);