[英]I am using fs module readdir but I keep getting this error (Error: ENOENT: no such file or directory, scandir)
I created a videos folder with videos in my react folder structure, I want to access the files in this folder and I came across the fs module, but no matter how many different solutions I tried, it shows that the file does not exist even though it is there.我在我的反应文件夹结构中创建了一个包含视频的视频文件夹,我想访问该文件夹中的文件并且遇到了 fs 模块,但是无论我尝试了多少不同的解决方案,它都显示该文件不存在,即使它在那里。
fs.readdir('./src/videos', (err, files) => { if (err) console.log(err); else { console.log(files); files.forEach(file => { console.log(file); }) } })
Your code is fine, make sure the path is correct.您的代码很好,请确保路径正确。 Check where the folder is in relation to where you are running the code from.
检查文件夹与运行代码的位置相关的位置。 Check the folder's name - make sure you don't have a typo.
检查文件夹的名称 - 确保您没有拼写错误。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.