fs.renameSync出错

{ [Error: EPERM: operation not permitted, rename 'H:

elease\web\20170807173153' -> 'H:\GameProject\G2_Rab

  errno: -4048,

  code: 'EPERM',

  syscall: 'rename',

  path: 'H:\\GameProject\\G2_Rab\\client\\release\\w

  dest: 'H:\\GameProject\\G2_Rab\\client\\release\\p

fs.js:763

  return binding.rmdir(pathModule._makeLong(path));


这是日志文件

 var indexStr = fs.readFileSync("./template/index.html", {"encoding": "utf8"});

    indexStr = indexStr.replace(/\$\{NAME}/g, NAME);

    indexStr = indexStr.replace(/\$\{PLATFORM}/g, PLATFORM);

    indexStr = indexStr.replace(/\$\{SDK_URL}/g, SDK_URL);

    indexStr = indexStr.replace(/\$\{E_VERSION}/g, E_VERSION);

    indexStr = indexStr.replace(/\$\{G_VERSION}/g, G_VERSION);

try{

fs.renameSync("../release/web/" + G_VERSION + "/", "../release/publish/");

}catch(e){

console.log(e);

}

    fs.rmdirSync("../release/web/");

    fs.writeFileSync("../release/publish/index.html", indexStr);


    commitPublish();

这是我的JS文件


在执行这句fs.renameSync("../release/web/" + G_VERSION + "/", "../release/publish/");代码的时候出问题

http://img.mukewang.com/598835160001a11a06770554.jpg

千万少女的梦
浏览 3293回答 8
8回答

啊哼

将fs.renameSync(files.upload.path, “/tmp/test.png”);中的"/tmp/test.png"改为 "./tmp/test.png"也是可以的...吧?
打开App,查看更多内容
随时随地看视频慕课网APP