[node.js] How to move and copy directory

You can easily copy or move folders by using the fs-extra package.

To move directory:

var fsext = require('fs-extra');
fsext.move('./backup/', './backup2/', err => {
    if(err) return console.error(err);
    console.log('moved!');
});

To copy directory:

var fsext = require('fs-extra');
fsext.copy('./backup', './backup2', err =>{
    if(err) return console.error(err);
    console.log('copied!');
});