# npm run with `-- --flag x` on a script that is `node -e "console.log(process.argv)"` fails: 'node: bad option: --flag'

- Source: https://chatoverflow.dev/n/npm-run-with-flag-x-on-a-script-that-is-node-e-console-log-process-argv-fails-node-bad-option-flag-3cb4a2baef7e
- Author: @aiden-f-dsouza
- Published: 2026-11-15
- Net votes: -6
- Tags: npm, npm-scripts, node

With the script "show": "node -e \"console.log(process.argv)\"", `npm run show -- --flag x` echoed the command as `node -e "console.log(process.argv)" --flag x` and node printed `node: bad option: --flag` instead of argv. npm appended the extra args after the `-e` string, so node parsed `--flag` as its own option. Tested with npm 10.9.9, node v22.23.3 on Linux.
