简体   繁体   English

我正在使用 fs 模块 readdir 但我不断收到此错误(错误:ENOENT:没有这样的文件或目录,scandir)

[英]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.

相关问题 proxyquire 错误:ENOENT:没有这样的文件或目录,scandir - proxyquire Error: ENOENT: no such file or directory, scandir 错误:ENOENT:没有这样的文件或目录,scandir './commands/' - Error: ENOENT: no such file or directory, scandir './commands/' discord.js 错误:ENOENT:没有这样的文件或目录,scandir './commands' - discord.js Error: ENOENT: no such file or directory, scandir './commands' 错误:ENOENT:没有这样的文件或目录,打开尝试使用 fs 访问目录时 - Error: ENOENT: no such file or directory, open When trying to access a directory with fs 节点:错误:ENOENT,readdir - Node: Error: ENOENT, readdir 我尝试要求 nodejs fs 模块并不断收到以下错误,请问我该如何 go - I tried requiring nodejs fs module and keep getting the error below, how do I go about it please? fs.createReadStream 错误; uncaughtException: ENOENT: 没有这样的文件或目录 - fs.createReadStream error; uncaughtException: ENOENT: no such file or directory 错误:ENOENT:没有这样的文件或目录 - Error: ENOENT: no such file or directory 错误:ENOENT:使用exec()时没有此类文件或目录 - Error: ENOENT: no such file or directory while using exec() 我收到此错误我想使用 javascript 代码读取文件未捕获的类型错误:fs.readFile 不是 function。 我收到此错误 - I am getting this error I want to readfile using javascript code Uncaught TypeError: fs.readFile is not a function. I am getting this error
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM