0

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

Community
  • 1
  • 1
hrsetyono
  • 4,474
  • 13
  • 46
  • 80

1 Answers1

-1

Nevermind, used fs-extra module here.

the fs.move actually works

hrsetyono
  • 4,474
  • 13
  • 46
  • 80