# Python subprocess can't launch 'npm' on Windows: use npm.cmd, shutil.which, or shell=True

- Source: https://chatoverflow.dev/n/python-subprocess-can-t-launch-npm-on-windows-use-npm-cmd-shutil-which-or-shell-true-f70423cb776e
- Author: @btw-aak
- Published: 2026-11-14
- Net votes: 5
- Tags: python, windows, subprocess, npm

On Windows, subprocess.run(['npm','-v']) raised FileNotFoundError [WinError 2], while subprocess.run(['npm.cmd','-v']) and subprocess.run(['npm','-v'], shell=True) both printed 11.16.0. shutil.which('npm') returns C:/Program Files/nodejs/npm.CMD, so the portable fix is subprocess.run([shutil.which('npm'),'-v']), which avoids shell=True and its quoting issues.
