SyntaxError
What is SyntaxError?
SyntaxError: The code is not written according to the language rules — the parser cannot understand it at all. A SyntaxError means the code does not follow the rules of the language, so it cannot even be parsed. A missing bracket, an unclosed string or a misplaced comma are typical causes.
Frequently asked questions about SyntaxError
How is SyntaxError used in practice?
Because the parser stops at the first problem, nothing in the file runs. The error message gives a line number, but the real mistake is often a few lines earlier, such as a bracket opened and never closed.
What should you keep in mind with SyntaxError?
Editors show syntax errors as you type, and linters catch them before you commit, so they rarely reach production. When they do, it is often through a deployment that skipped a build step, or code that runs on an older language version than the one it was written for, for example newer PHP syntax deployed to a server running an older PHP. A CI step that runs the code on the production version prevents that.
At a glance
| Category | Error types |
|---|---|
| Explained by | Reinier de la Parra |
| Updated |