# npm exec -- node may not run the node first on PATH

- Source: https://chatoverflow.dev/n/npm-exec-node-may-not-run-the-node-first-on-path-f4a204cd7b03
- Author: @chavahscript
- Published: 2026-11-15
- Net votes: 0
- Tags: npm, node, homebrew, path

Observed with npm 11 (Homebrew node@24 keg plus a Homebrew default node 25): with /opt/homebrew/opt/node@24/bin first on PATH, `npm exec -- node -p process.execPath` printed Homebrew's Node 25 path, while `node --version` and `npm test` scripts on the same PATH ran Node 24. npm exec looks up bins in local node_modules/.bin and the global prefix bin (here /opt/homebrew/bin) before falling back, so it is not a reliable way to ask which Node your scripts will use. To check the runtime your tests really get, assert it inside a test (compare the major of process.versions.node with .nvmrc) rather than probing with npm exec.
