Uncaught SyntaxError
Uncaught SyntaxError: await is only valid in async functions and the top level bodies of modules
await the top level bodies of modules
Can not Run normally
<script type="text/javascript">
// Uncaught SyntaxError: await is only valid in async functions and the top level bodies of modules
let x = await tools();
console.log(x);
</script>
After modification
reference resources
<script type="text/javascript">
// demo
(async () => {
let x = await tools();
console.log(x);
})();
</script>
Read More:
- Parsing error: await is a reserved word [How to Solve]
- [Solved] JS Error: Uncaught SyntaxError: Illegal return statement
- [Solved] Vue Error: Error in v-on handler (Promise/async): “[object object]“
- [Solved] Vue-vscode Error: Parsing error: Unexpected reserved word ‘await‘.
- [Solved] react-router-dom Error: index.js:1 Warning: Functions are not valid as a React child.
- [Solved] Uncaught SyntaxError: Cannot use import statement outside a module
- [Solved] This dependency was not found: * core-js/modules/es.error.cause.js in ./node_modules/_@babel_runtim
- vue Error: Uncaught SyntaxError: Invalid shorthand property initializer
- Vue Error: Error in v-on handler (Promise/async): “Error: Error“
- Failed to resolve async component default: ChunkLoadError: Loading chunk 7 failed
- Module not found: Error: Can‘t resolve ‘core-js/modules/es.promise.js‘ in
- JS bug Log Uncaught TypeError: Cannot read property ‘previoustSibling‘ of null
- [Solved] Uncaught SyntaxError: Invalid Unicode escape sequence
- [Solved] Binding onclick event in JS: for loop: error uncaught typeerror: cannot set properties of undefined (setting ‘classname’)
- js: SyntaxError: Cannot use import statement outside a module
- [Solved] Uncaught SyntaxError: The requested module does not provide an export named
- node.js yarn Error: SyntaxError: Unexpected string [How to Solve]
- [Solved] ajax Error: Uncaught SyntaxError: Unexpected end of JSON input
- [Solved] SyntaxError: E:\IdeaProject\src\main.js: Identifier ‘ElementPlus‘ has already been declared
- [Solved] Turf.js error: uncaught (in promise) error: the solution of invalid unit