【发布时间】:2012-06-20 03:35:01
【问题描述】:
我正在尝试使用 nodejs 的 WGET 方法进行文件下载。我发现了这个:
var exec = require('exec');
// Function to download file using wget
var download_file_wget = function(file_url) {
// extract the file name
var file_name = url.parse(file_url).pathname.split('/').pop();
// compose the wget command
var wget = 'wget -P ' + DOWNLOAD_DIR + ' ' + file_url;
// excute wget using child_process' exec function
var child = exec(wget, function(err, stdout, stderr) {
if (err) throw err;
else console.log(file_name + ' downloaded to ' + DOWNLOAD_DIR);
});
};
但它说:
Error: Cannot find module 'exec'
exec 是另一个要安装和导入的模块吗.. 或者我怎样才能让它工作?
【问题讨论】:
标签: http node.js download exec wget