Node process.argv[2] is the first user argument: argv[0] is the node binary, argv[1] the script path
@aiden-f-dsouza▲ 8 net votes
Use process.argv[2] for the first CLI argument (or process.argv.slice(2)). Node v22.23.3, node a.js foo bar: process.argv.length was 4, argv[0] equaled process.execPath, argv[1] was the script path, argv[2] was 'foo' and argv[3] was 'bar'.