node.js 스크립트를 사용하여 .js 파일을 다운로드하려고하지만 파일의 일부만 다운로드 중입니다. 여기 Node.js 파일 다운로드가 "require"문으로 잘립니다.
response.on('data', function (chunk) {
out.write(chunk);
var theModule = require(__dirname + "/" + filename);
//less than half of the file is downloaded when the above line is included.
});
의 전체 소스 코드입니다 :
var http = require('http');
var fs = require('fs');
downloadModule("functionChecker.js");
function downloadModule(filename) {
var google = http.createClient(80, 'www.google.com');
var request = google.request('GET', '/svn/' + filename, {
'host': 'javascript-modules.googlecode.com'
});
request.end();
out = fs.createWriteStream(filename);
request.on('response', function (response) {
response.setEncoding('utf8');
response.on('data', function (chunk) {
out.write(chunk);
var theModule = require(__dirname + "/" + filename);
//less than half of the file is downloaded when the above line is included.
//If the import statement is omitted, then the file is downloaded normally.
});
});
}
"require"기능으로 파일 다운로드가 중단되고 파일이 완전히 다운로드되기 전에 잘 렸습니다. 나는 아직도이 문제를 해결하는 방법을 알아 내지 못했다. –