简体   繁体   English

files.forEach((file) => { TypeError: 无法读取未定义的属性(读取 'forEach')

[英]files.forEach((file) => { TypeError: Cannot read properties of undefined (reading 'forEach')

I already search solutions for this problem but all I can find is "missing semi colon" which is obviously not my problem... Here are the code and its error我已经搜索了这个问题的解决方案,但我能找到的只是“缺少分号”,这显然不是我的问题......这是代码及其错误

Node.JS MongoDB File-Upload Node.JS MongoDB 文件上传

Can anyone help me?谁能帮我?

I already search solutions for this problem but all I can find is "missing semi colon" which is obviously not my problem我已经搜索了这个问题的解决方案,但我能找到的只是“缺少分号”,这显然不是我的问题

Use fs.readdirSync in line 41 instead.请改用第 41 行中的fs.readdirSync

Based on the error log you provided, the files Is not defined.根据您提供的错误日志, files未定义。 Add a guard clause at line 47 to check field exist before running the code在第 47 行添加一个 guard 子句以在运行代码之前检查字段是否存在

if (files && files.length >0){

//original line 47-52
}

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 files.forEach(function(file){^ TypeError:无法读取未定义的属性'forEach' - files.forEach(function(file) { ^ TypeError: Cannot read property 'forEach' of undefined TypeError:无法读取未定义的属性(读取“forEach”) - TypeError: Cannot read properties of undefined (reading 'forEach') TypeError:无法读取未定义的属性(读取'forEach) - TypeError: Cannot read properties of undefined (reading 'forEach) Angular:类型错误:无法使用 Treeview 读取未定义的属性(读取“forEach”) - Angular: TypeError: Cannot read properties of undefined (reading 'forEach') with Treeview TypeError: Cannot read properties of undefined (reading 'forEach') 如何解决这个问题? - TypeError: Cannot read properties of undefined (reading 'forEach') How to overcome this problem? 无法在我的 Messenger Webhook 事件中读取未定义的属性(读取“forEach”) - Cannot read properties of undefined (reading 'forEach') in my messenger webhook event 类型错误:无法读取未定义的属性“forEach” - TypeError: Cannot read property 'forEach' of undefined TypeError:无法读取 ejs 文件未定义的属性“forEach” - TypeError: Cannot read property 'forEach' of undefined of ejs file 类型错误:无法读取未定义 Javascript 的属性“forEach” - TypeError: Cannot read property 'forEach' of undefined Javascript TypeError:无法读取未定义的属性(读取'indexOf') - TypeError: Cannot read properties of undefined (reading 'indexOf')
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM