现在的位置: 首页 > 综合 > 正文

Use command line arguments in Node.js

2013年10月20日 ⁄ 综合 ⁄ 共 171字 ⁄ 字号 评论关闭
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

【上篇】
【下篇】

抱歉!评论已关闭.