How do I move file a to a different partition or device in Node.js?

后端 未结 5 1161
终归单人心
终归单人心 2020-11-30 04:36

I\'m trying to move a file from one partition to another in a Node.js script. When I used fs.renameSync I received Error: EXDEV, Cross-device link.

5条回答
  •  旧时难觅i
    2020-11-30 05:13

    to import the module and save it to your package.json file

    npm install mv --save
    

    then use it like so:

    var mv = require('mv');
    
    mv('source_file', 'destination_file', function (err) {
        if (err) {
            throw err;
        }
        console.log('file moved successfully');
    });
    

提交回复
热议问题