【问题标题】:NodeJS - error EPERM when moving file to its parent directory?NodeJS - 将文件移动到其父目录时出错 EPERM?
【发布时间】:2015-10-27 18:15:10
【问题描述】:

我发现这个answer 说要使用mv 模块。

但如果我想将文件移动到其父目录,它似乎不起作用。

例如我想将/tmp上的所有文件移动到/

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); }
});

我得到了这个错误:

error:  Error: EPERM, rename 'C:\Users\myusername\Documents\test\tmp'

我认为这是因为在 NodeJS 中移动使用了rename 解决方法,它无法将其重命名为父目录。

有什么解决办法吗?谢谢

【问题讨论】:

    标签: node.js fs


    【解决方案1】:

    没关系,用fs-extra模块here

    fs.move 确实有效

    【讨论】:

      猜你喜欢
      • 2016-05-03
      • 1970-01-01
      • 2017-10-09
      • 2017-05-27
      • 1970-01-01
      • 1970-01-01
      • 2018-10-02
      • 2013-04-14
      • 1970-01-01
      相关资源
      最近更新 更多