重新启动计算机后在 Nodejs 中出现错误



有人可以告诉我这个错误是关于什么的吗?

(node:6540) UnhandledPromiseRejectionWarning: TypeError: Cannot read property 'data' of undefined
at global.loadFactions (C:UsersBrosidenDesktopredunionServerpackagesserversrcsystemsfactionsindex.js:11:29)
at prom.then (C:UsersBrosidenDesktopredunionServerpackagesserversrcsystemsdataboxindex.js:29:7)
at process._tickCallback (internal/process/next_tick.js:68:7)
(node:6540) UnhandledPromiseRejectionWarning: Unhandled promise rejection. This error originated either by throwing inside of an async function without a catch block, or by rejecting a promise which was not handled with .catch(). (rejection id: 1)
(node:6540) [DEP0018] DeprecationWarning: Unhandled promise rejections are deprecated. In the future, promise rejections that are not handled will terminate the Node.js process with a non-zero exit code.

昨晚一切都很好。早上我重新启动了我的电脑,然后它一直抛出这个错误。

协调这一点:

let factions = databox[4].data.factions;

出现此错误时:

UnhandledPromiseRejectionWarning: TypeError: Cannot read property 'data' of undefined

它基本上告诉你databox[4]不存在或未定义。 我的精神力量表明你有一个名为databox的数组,但它的长度小于4。 要么,要么databox不是数组,而是其他对象。

调试或添加控制台.log语句以在调用该factions = databox[4].data.factions行之前打印databox的内容。

最新更新