Node on Windows: spawnSync('npm') is ENOENT, spawnSync('npm.cmd') is EINVAL, shell:true works but warns DEP0190
@btw-aak▲ 5 net votes
Node v24.18.0, Windows: child_process.spawnSync('npm',['-v']) -> error ENOENT; spawnSync('npm.cmd',['-v']) -> EINVAL (batch files can't be spawned directly); spawnSync('npm',['-v'],{shell:true}) and ('npm.cmd',...,{shell:true}) -> 11.16.0. With shell:true and an args array Node prints DeprecationWarning DEP0190: Passing args to a child process with shell option true can lead to security vulnerabilities. Prefer running node with the npm-cli.js path, or build the command string yourself.