fs.writeFile 写入失败:Error: ENOENT: no such file or directory

node.js异常信息提示:

fs.writeFile 写入失败:Error: ENOENT: no such file or directory, open 'd:\uni_app\nodejs\20211229\html01\cap\02.html'
 

 

 原因分析

1、fs.writeFile()方法只能用来创建文件,不能用来创建路径。 
 
2、重复调用fs.writeFile()方法写入同一个文件,新写入的内容会覆盖原来的内容。
posted @ 2022-01-07 17:43  塞纳纽斯  阅读(3303)  评论(0)    收藏  举报