Added list check after connect to check if list is empty :
var ftpQual = new ftpClient(ftpConfig, ftpOptions);
ftpQual.connect(function () {
ftpQual.ftp.list('/', function (err, list) {
if(err){
return callback(err);
}
if( list.length === 0 ) { // because ftp-clients crashes if dir is empty
return callback(null, localDir);
}
ftpQual.download('/', localDir, { overwrite: 'all' },
function(result) {
callback(null, localDir);
}
);
})
});
Don't hesitate...
Added list check after connect to check if list is empty : var ftpQual = new ftpClient(ftpConfig, ftpOptions); ftpQual.connect(function () { ftpQual.ftp.list('/', function (err, list) { if(err){ return callback(err); } if( list.length === 0 ) { // because ftp-clients crashes if dir is empty return callback(null, localDir); } ftpQual.download('/', localDir, { overwrite: 'all' }, function(result) { callback(null, localDir); } ); }) }); Don't hesitate...