Javascript 我得到;TypeError:无法读取属性';标签';“无效”的定义;但仅在discord.js bot的打包版本中

Javascript 我得到;TypeError:无法读取属性';标签';“无效”的定义;但仅在discord.js bot的打包版本中,javascript,node.js,package,discord.js,Javascript,Node.js,Package,Discord.js,我正在discord.js中开发一个discord机器人,一切都很好。但我想将其编译成一个.exe文件以便于使用,等等。我可以使用node.js运行bot,但当我运行.exe时,会收到以下错误消息: (node:3656) UnhandledPromiseRejectionWarning: TypeError: Cannot read property 'tag' of null at Client.<anonymous> (C:\snapshot\src\index.js:

我正在discord.js中开发一个discord机器人,一切都很好。但我想将其编译成一个.exe文件以便于使用,等等。我可以使用node.js运行bot,但当我运行.exe时,会收到以下错误消息:

(node:3656) UnhandledPromiseRejectionWarning: TypeError: Cannot read property 'tag' of null
    at Client.<anonymous> (C:\snapshot\src\index.js:19:42)
    at Client.emit (events.js:315:20)
    at WebSocketManager.triggerClientReady (C:\snapshot\src\node_modules\discord.js\src\client\websocket\WebSocketManager.js:431:17)
    at WebSocketManager.checkShardsReady (C:\snapshot\src\node_modules\discord.js\src\client\websocket\WebSocketManager.js:415:10)
    at WebSocketShard.<anonymous> (C:\snapshot\src\node_modules\discord.js\src\client\websocket\WebSocketManager.js:197:14)
    at WebSocketShard.emit (events.js:315:20)
    at WebSocketShard.checkReady (C:\snapshot\src\node_modules\discord.js\src\client\websocket\WebSocketShard.js:475:12)
    at WebSocketShard.onPacket (C:\snapshot\src\node_modules\discord.js\src\client\websocket\WebSocketShard.js:447:16)
    at WebSocketShard.onMessage (C:\snapshot\src\node_modules\discord.js\src\client\websocket\WebSocketShard.js:301:10)
    at WebSocket.onMessage (C:\snapshot\src\node_modules\ws\lib\event-target.js:132:16)
(Use `jamesinasbot --trace-warnings ...` to show where the warning was created)
(node:3656) 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(). To terminate the node process on unhandled promise rejection, use the CLI flag `--unhandled-rejections=strict` (see https://nodejs.org/api/cli.html#cli_unhandled_rejections_mode). (rejection id: 1)
(node:3656) [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.
(节点:3656)未处理的PromisejectionWarning:TypeError:无法读取null的属性“tag”
在客户端。(C:\snapshot\src\index.js:19:42)
在Client.emit(events.js:315:20)
在WebSocketManager.triggerclientrady(C:\snapshot\src\node\u modules\discord.js\src\client\websocket\WebSocketManager.js:431:17)
在WebSocketManager.checkShardsReady(C:\snapshot\src\node\u modules\discord.js\src\client\websocket\WebSocketManager.js:415:10)
在WebSocketShard。(C:\snapshot\src\node\u modules\discord.js\src\client\websocket\WebSocketManager.js:197:14)
在WebSocketShard.emit(events.js:315:20)
在WebSocketShard.checkReady(C:\snapshot\src\node\u modules\discord.js\src\client\websocket\WebSocketShard.js:475:12)
在WebSocketShard.onPacket(C:\snapshot\src\node\u modules\discord.js\src\client\websocket\WebSocketShard.js:447:16)
在WebSocketShard.onMessage(C:\snapshot\src\node\u modules\discord.js\src\client\websocket\WebSocketShard.js:301:10)
在WebSocket.onMessage(C:\snapshot\src\node\u modules\ws\lib\event target.js:132:16)
(使用'jamesinasbot--trace warnings…`显示警告的创建位置)
(节点:3656)未处理的PromisejectionWarning:未处理的承诺拒绝。此错误源于在没有catch块的异步函数中抛出,或者拒绝未使用.catch()处理的承诺。要在未处理的承诺拒绝时终止节点进程,请使用CLI标志“---unhandled rejections=strict”(请参阅https://nodejs.org/api/cli.html#cli_unhandled_rejections_mode). (拒绝id:1)
(节点:3656)[DEP0018]弃用警告:未处理的承诺拒绝已弃用。将来,未处理的承诺拒绝将使用非零退出代码终止Node.js进程。
这就是问题所在:
console.log(`Logged as${client.user.tag}.`)

我不知道为什么会这样。我已经确保所有依赖项都包含在内,它与index.js位于同一个目录中,而且因为它只是说它无法读取null的属性标记,所以它似乎是变量问题,或者不是依赖项问题。我尝试过使用--trace警告,但它没有显示任何不同


感谢您的帮助

我跟踪了错误堆栈,发现这行代码位于代码的
client#ready
事件侦听器中。请提供您的整个侦听器好吗?我跟踪了错误堆栈,发现这行代码位于代码的
client\ready
事件侦听器中。你能提供你全部的听众吗?