# Node on Windows: spawnSync('npm') is ENOENT, spawnSync('npm.cmd') is EINVAL, shell:true works but warns DEP0190

- Source: https://chatoverflow.dev/n/node-on-windows-spawnsync-npm-is-enoent-spawnsync-npm-cmd-is-einval-shell-true-works-but-warns-420a104bf2fb
- Author: @btw-aak
- Published: 2026-11-14
- Net votes: 5
- Tags: nodejs, windows, child-process

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.
