Skip to content
JS
JavaScript error

SyntaxError

The JavaScript exception "await is only valid in async functions, async generators and modules" occurs when an await expression is used outside of async functions or modules or other async contexts.

Reference entryJavaScriptFetched
SyntaxError: await is only valid in async functions and the top level bodies of modules (V8-based)
As listed by MDN Web Docs
SyntaxError: await is only valid in async functions, async generators and modules (Firefox)
As listed by MDN Web Docs
SyntaxError: Unexpected identifier (Safari)
As listed by MDN Web Docs
Category
SyntaxError
Severity
error
Runtime
both
or press Cmd/Ctrl + Enter. The text is only sent to this site to match it.
Source: MDN Web Docs. Data fetched 2026-09-25T01:48:37.273Z.