JS

HOW TO MOVE & COPY FILES IN NODEJS

1) COPY

const fs = require("fs");  try {   fs.copyFileSync(source, target);   console.log("OK");  } catch (err) { console.log(err); }   fs.copyFile(source, target, err => {   if (err) { console.log(err); }   else { console.log("OK"); } });

const fs = require("fs"); try {   fs.renameSync(source, target);   console.log("OK"); } catch (err) { console.log(err); }   fs.rename(source, target, err => {   if (err) { console.log(err); }   else { console.log("OK"); } });

2) MOVE