I wish to create a Node.js script to copy files overwriting previous versions of the same files. My code doesn't work:
const fs = require('fs');
var src = "srcPath/file.json";
var newPath = "newPath/file.json";
var callback = (result) => {
console.log(result);
}
copy(src, newPath, callback);
function copy(src, newPath, callback){
fs.copyFile(src, newPath, (err) => {
if (err) {
callback("Error Found:", err);
}
else {
callback("Success: " newPath);
}
});
}
execute()
CodePudding user response:
It will work, if you take this line off:
execute()