NodeJS,fs.copyFileSync无法正常工作并且不会引发错误

时间:2019-07-31 08:20:00

标签: javascript node.js fs

我正在使用nodeJS类fs使用循环将文件从文件夹复制到另一个文件夹。问题在于此功能不起作用。它阻止了“ fs.copyFileSync”,但这不会引发错误

for(var i=0; i<pdf.length; i++) {

    console.log('STEP 1');

    //vmsy03/s$/Commesse/115400_BREBEMI/Opere/CE010/Report/CE010_Anomalie_2018.pdf
    var pathSource = pdf[i].path;

    console.log('STEP 2');

    //C:\Users\AFFATI~1\AppData\Local\Temp/SIOS4/CE010_RapportoIspezione_2018rev0/evalDocument_0.pdf
    var pathDestination = info.files_data.path.base + "/evalDocument_" + i + ".pdf";

    console.log('STEP 3');


    fs.copyFile(pathSource, pathDestination, (err) => {

        console.log('STEP 4');

        if (err) { 
            console.log('error ' + err);
            throw err;
        }
        console.log(pathSource + ' was copied to ' + pathDestination);
    });

    console.log('STEP 5');


    info.files_data.files.push(pathDestination);
    info.visualEvalDoc["controlDocTitle" + i] = pdf[i].docTitle;        

    console.log('STEP 6');
}

我不知道它为什么被阻止,有什么建议吗?

编辑:节点版本:4.4.6
这就是日志记录的情况(我还用所有日志编辑了该函数)

enter image description here

0 个答案:

没有答案