SyntaxError: Unexpected Token

Hello. I get this in my project:

SyntaxError: Unexpected token !

Jump to at Object.Actions.eval (/app/bot.js:321:15)

Jump to at Object.action [as Check Variable] (/app/actions/check_variable.js:163:33)

Jump to at Object.Actions.callNextAction (/app/bot.js:507:18)

Jump to at Object.action [as Store Member Info] (/app/actions/store_member_info.js:336:7)

Jump to at Object.Actions.callNextAction (/app/bot.js:507:18)

Jump to at Object.Actions.executeResults (/app/bot.js:890:10)

Jump to at Object.action [as Check Member Permissions] (/app/actions/check_member_permissions.js:114:7)

Jump to at Object.Actions.callNextAction (/app/bot.js:507:18)

Jump to at Object.Actions.executeResults (/app/bot.js:865:10)

Jump to at Object.action [as Check Server Data] (/app/actions/check_server_data.js:197:7)

I am not sure what to do, could anyone help me?

Hey there, @Lillishaj2!

A SyntaxError is thrown when the JavaScript engine encounters tokens or token order that does not conform to the syntax of the language when parsing code.

To solve the issue, I’ll recommend your to use a linter for JavaScript - there are tons of linter out there, however, I prefer ESLint.
If you want to lint your code online, check out javascriptlint.com

Here are some common mistakes that JavaScript Lint looks for:

  • Missing semicolons at the end of a line.
  • Curly braces without an if, for, while, etc.
  • Code that is never run because of a return, throw, continue, or break.
  • Case statements in a switch that do not have a break statement.
  • Leading and trailing decimal points on a number.
  • A leading zero that turns a number into octal (base 8).
  • Comments within comments.
  • Ambiguity whether two adjacent lines are part of the same statement.
  • Statements that don’t do anything.

Read more: SyntaxError - MDN

Cheerio!

Hi @Lillishaj2, welcome to the Glitch forum!

@chroventer’s comments might be helpful indeed. One thing to keep in mind is that when Node tells you there’s an unexpected token, it means that there’s a character somewhere in whatever command you’re asking it to execute that it doesn’t know how to interpret - possibly a misplaced comma or brace or something along those lines.

We can’t tell what that might be without looking at your code - if you care to share your project name someone might be able to take a look and provide some specific advice. Also, if your bot accepts arbitrary commands from its users it’s possible this error is actually in whatever command is being sent and not in your bot’s code.

1 Like