Use command line arguments in Node.js

var args = process.argv.splice(2);
if(!args || args.length ==0){
	console.log("no params");
}

for(var i=0;i<args.length;i++)
	console.log(args[i]);


commandline:
node test1.js a b c d
output: a
b
c
d

你可能感兴趣的:(Use command line arguments in Node.js)