node.js でコマンドライン引数を取りたい場合は opts というモジュールを使うことで簡単に実現出来ます。 optsモジュールは npm でインストールします。 var http = require('http') , opts = require('opts'); opts.parse([ { 'short': 'p', 'long': 'port', 'description': 'HTTP port', 'value': true, 'required': false }, ]); var port = opts.get('port') || 3000 server = http.createServer(function(req, res) { res.writeHead(200, {'Content-Type': 'text/html'}); res.write('<
![node.js で コマンドライン引数を取るには](https://cdn-ak-scissors.b.st-hatena.com/image/square/664033f87bdc379cf0578c7ade00269d8d4144f6/height=288;version=1;width=512/https%3A%2F%2Fblog.dakatsuka.jp%2Fimages%2Fcard.png)