Skip to content

Instantly share code, notes, and snippets.

@mazzo46
Created December 3, 2012 14:53
Show Gist options
  • Save mazzo46/4195464 to your computer and use it in GitHub Desktop.
Save mazzo46/4195464 to your computer and use it in GitHub Desktop.
command line parameters in node.js

When you type like this:

> node hoge.js a b c

You'll get:

argv[0] : node
argv[1] : /path/to/hoge.js
argv[2] : a
argv[3] : b
argv[4] : c
for(var i=0; i<process.argv.length; i++) {
console.log('argv['+i+'] : ' + process.argv[i]);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment