I found this answer saying to use mv
module.
But it doesn't seem it works if I want to move file to its parent directory.
For example I want to move all files on /tmp
to /
var root = process.cwd(); // the directory where i run the script
mv(root + "/tmp", root, { mkdirp: true }, function(err) {
if(err) { return logger.error(err); }
});
and I got this error:
error: Error: EPERM, rename 'C:\Users\myusername\Documents\test\tmp'
I think it's because moving in NodeJS uses rename
workaround and it can't rename it to the parent directory.
Any solution? Thanks