简体   繁体   English

TypeError: fn is not a function - 但我没有在我的文件中写 fn

[英]TypeError: fn is not a function - but I didn't write fn in my file

I have no idea how this happened, I was just working on my code when all of a sudden, I get an error from another file.我不知道这是怎么发生的,我只是在处理我的代码,突然,我从另一个文件中得到一个错误。 I didn't write fn anywhere in the file I was working in. The file I am working in is C:/Users/---/Discord Bot/index.js but I got the error from C:/Users/---/Discord Bot/node_modules/@discordjs/collection/dist/index.js - line 161 col 17 and I did see if(fn(val, key, this)) on that line but I changed NOTHING in that file, I didn't even know it existed before now.我没有在我正在使用的文件中的任何地方写 fn。我正在使用的文件是C:/Users/---/Discord Bot/index.js但我从C:/Users/---/Discord Bot/node_modules/@discordjs/collection/dist/index.js - line 161 col 17得到错误C:/Users/---/Discord Bot/node_modules/@discordjs/collection/dist/index.js - line 161 col 17 ,我确实在该行看到了if(fn(val, key, this))但我在该文件中没有更改任何内容,我没有甚至不知道它以前存在过。 What do I do?我该怎么办? Another npm install discord.js ?另一个npm install discord.js I only recently got it anyways.反正我是最近才拿到的。 Here's the full error message in case you might need it.这是完整的错误消息,以防您可能需要它。

    at Map.find (C:\Users\---\Discord Bot\node_modules\@discordjs\collection\dist\index.js:161:17)
    at Client.<anonymous> (C:\Users\---\Discord Bot\index.js:394:56)
    at Client.emit (node:events:381:22)
    at MessageCreateAction.handle (C:\Users\---\Discord Bot\node_modules\discord.js\src\client\actions\MessageCreate.js:31:14)    at Object.module.exports [as MESSAGE_CREATE] (C:\Users\---\Discord Bot\node_modules\discord.js\src\client\websocket\handlers\MESSAGE_CREATE.js:4:32)
    at WebSocketManager.handlePacket (C:\Users\---\Discord Bot\node_modules\discord.js\src\client\websocket\WebSocketManager.js:384:31)
    at WebSocketShard.onPacket (C:\Users\---\Discord Bot\node_modules\discord.js\src\client\websocket\WebSocketShard.js:444:22)
    at WebSocketShard.onMessage (C:\Users\---\Discord Bot\node_modules\discord.js\src\client\websocket\WebSocketShard.js:301:10)
    at WebSocket.onMessage (C:\Users\---\Discord Bot\node_modules\ws\lib\event-target.js:132:16)
    at WebSocket.emit (node:events:369:20)

So re-installing discord.js won't help you.所以重新安装 discord.js 对你没有帮助。 the fn on that line get's set by you on your index.js该行的fnindex.js 上设置

For Example you perhaps run message.channel.find(VARIABLE) fn gets set to VARIABLE and then it tries to runs fn as a function even if VARIABLE isn't a function.例如,您可能运行message.channel.find(VARIABLE) fn设置为VARIABLE ,然后它尝试将fn作为 function 运行,即使VARIABLE不是 function。

Now I do not know where fn get's set ( too lazy to check through the code ), but it does get set by you when you pass in a variable.现在我不知道fn get 设置在哪里(懒得检查代码),但是当你传入一个变量时它确实被你设置了。

My guess is that it's on line 394 of YOUR index.js as that's when a chain of actions happen leading to fn being called.我的猜测是它在您的index.js的第394行,因为那是发生一系列动作导致调用fn的时候。

This is about the best one can do without your code, and full error.这是没有您的代码和完全错误可以做到的最好的事情。 You've given us the trace not the error.您给了我们跟踪而不是错误。 And without your code related to index.js#394 we can't help further.如果没有您与index.js#394相关的代码,我们将无能为力。

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

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM