以下是我的代碼Learnyounode教程#11 HTTP文件服務器
var http = require('http');
var fs = require('fs');
var arguments = process.argv;
var path = process.argv[3];
var path2 = arguments[3];
var server = http.createServer(
function (req, res)
{
console.log('path1'+path);
console.log('path2'+path2);
console.log('path3'+arguments[3]);
var fileStream = fs.createReadStream(arguments[3]);
fileStream.pipe(res);
}
);
server.listen(arguments[2]);
,如果我傳遞給fs.createReadStream()路徑或路徑2,我的代碼工作,但如果我傳遞參數[3],它失敗,console.log(path3)也打印未定義。我不明白這一點。有人請解釋。謝謝。
'path2'打印正確的輸出的名字嗎? – Minato