node.js, getting command line arguments
In node js, the command line arguments are stored in process.argv. The first argument is always “node” and the second argument is always the file name of the nodejs script, the third and the following are arguments you can pass into the nodejs script. For example, this piece of code will print all the command line arguments when you run it. /home/getCommandLineArgs.js
for(var i=0; i<process.argv.length; i++) console.log(process.argv[i]);
For command: node /home/getCommandLineArgs.js
node /home/getCommandLineArgs.js
For command: node /home/getCommandLineArgs.js abc
node /home/getCommandLineArgs.js abc
For command: node /home/getCommandLineArgs.js abc 123
node /home/getCommandLineArgs.js abc 123
Search within Codexpedia
Custom Search
Search the entire web
Custom Search
Related Posts