javascript - 节点文件系统模块重命名方法
问题描述
我正在尝试使用文件系统库中的重命名方法更改文件名,文件名已更改,但出现如下错误:
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
解决方案
推荐阅读
- arrays - get object from array of arrays
- shell - 在 shell 中执行但不能从 bash 脚本文件中工作时工作
- vega-lite - 如何在 vega-lite 堆叠条形图中控制组的顺序
- android - 在 Qt Creator (Windows) 中构建 Qt 库的问题
- react-native - 如何通过 ref 获取 textinput 的文本/值?
- windows - 我想复制现有的配置文件规则并将它们添加到新的配置文件中。可以使用“赎回.dll”吗?
- c++ - MSVC 2010 编译的应用程序和 MSVC 2019 编译的应用程序之间的行为差异
- jira - in jira server my burndown does not reflect my done work
- c - *(x+i) 等同于 &x[i]?
- python - fillna() 不替换 NaN 值