节点文件系统模块重命名方法

时间:2019-04-03 21:11:40

标签: javascript node.js

我正在尝试使用文件系统库中使用重命名方法的文件名来更改文件名,但出现如下错误:

const fs = require("fs");
fs.renameSync("./name.js", "anothername.js");

Error: ENOENT: no such file or directory, rename './changed.js' -> 'another.js'
    at Object.renameSync (fs.js:614:3)
    at Object.<anonymous> (/home/lenovo/Desktop/test.js:2:4)
    at Module._compile (internal/modules/cjs/loader.js:738:30)
    at Object.Module._extensions..js (internal/modules/cjs/loader.js:749:10)
    at Module.load (internal/modules/cjs/loader.js:630:32)
    at tryModuleLoad (internal/modules/cjs/loader.js:570:12)
    at Function.Module._load (internal/modules/cjs/loader.js:562:3)
    at Function.Module.runMain (internal/modules/cjs/loader.js:801:12)
    at internal/main/run_main_module.js:21:11

0 个答案:

没有答案