Node.js 指示超出文件末尾的意外标记

发布于 2024-12-29 17:20:54 字数 1056 浏览 1 评论 0原文

我正在 Node.js 中开发一个非常简单的机器人,但它不会再启动了。 Node.js 指示意外令牌错误,但列出的行号超出了文件末尾。具体来说,错误是:

C:\Users\Owner\Bot\jovial_bot.js:294
});
 ^

node.js:201
        throw e; // process.nextTick error, or 'error' event on first tick
              ^
SyntaxError: Unexpected token )
    at Module._compile (module.js:427:25)
    at Object..js (module.js:450:10)
    at Module.load (module.js:351:31)
    at Function._load (module.js:310:12)
    at Array.0 (module.js:470:10)
    at EventEmitter._tickCallback (node.js:192:40)

The last line in the program is } ); 但是,最后一行是第 293 行。在文件末尾添加换行符会增加 Node.js 报告的行号。据我所知,我没有任何不匹配的括号。我尝试将 ( 添加到文件末尾,错误更改为“意外的标记}”。添加“ ({”将错误更改为“意外的输入结束”。我不知道在哪里继续。谢谢 我的代码

在这里:http://jsfiddle.net/kunkelwe/VEBtH/ 我正在使用这个 API: https://github.com /alaingilbert/Turntable-API/blob/master/turntable_data/deregistered.js

I'm developing a pretty simple bot in Node.js, and it won't launch anymore. Node.js is indicating an unexpected token error, but the line number listed is past the end of the file. Specifically, the error is:

C:\Users\Owner\Bot\jovial_bot.js:294
});
 ^

node.js:201
        throw e; // process.nextTick error, or 'error' event on first tick
              ^
SyntaxError: Unexpected token )
    at Module._compile (module.js:427:25)
    at Object..js (module.js:450:10)
    at Module.load (module.js:351:31)
    at Function._load (module.js:310:12)
    at Array.0 (module.js:470:10)
    at EventEmitter._tickCallback (node.js:192:40)

The last line in the program is } ); However, the last line is line number 293. Adding newlines to the end of the file increases the line number reported by Node.js. As far as I can tell, I do not have any unmatch parenthesis. I tried adding ( to the end of the file, and the error changed to "Unexpected token }". Adding " ({ " changed the error to "Unexpected end of input". I don't know where to continue with this. Thank you in advance for the help.

My code is here: http://jsfiddle.net/kunkelwe/VEBtH/
And I'm using this API: https://github.com/alaingilbert/Turntable-API/blob/master/turntable_data/deregistered.js

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

大海や 2025-01-05 17:20:54

您在 102 行缺少 }。您在 74 行打开了一个名为 toggle_mode 的函数,但从未放置过结束 }

...

function toggle_mode( mode ) {
    switch( mode ) {
        ...
    }
// ** missing a '}' here **

//Events////////////////////////////////////////////////////////////////////////////////////////
bot.on( 'ready', function( data ) { //Join the room
    bot.roomRegister(ROOMID);
} );

...

You are missing a } on line 102. You open a function called toggle_mode on line 74 but you never put a closing }.

...

function toggle_mode( mode ) {
    switch( mode ) {
        ...
    }
// ** missing a '}' here **

//Events////////////////////////////////////////////////////////////////////////////////////////
bot.on( 'ready', function( data ) { //Join the room
    bot.roomRegister(ROOMID);
} );

...
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文