Cannot use keyword 'await' outside an async function
See original GitHub issueBug report
What is the current behavior?
ERROR in ./app/src/ui/charts/export/png.ts 190:11
Module parse failed: Cannot use keyword 'await' outside an async function (190:11)
File was processed with these loaders:
* ./node_modules/babel-loader/lib/index.js
You may need an additional loader to handle the result of these loaders.
| });
| toBlob = async () => {
> return await this.toCanvas().then(canvasToBlob);
| };
| }
If the current behavior is a bug, please provide the steps to reproduce.
I believe it’s an issue with a class property which is an async function. Webpack is not able to handle the case below:
class A {
m = async () => {
return await Promise.resolve();
};
}
What is the expected behavior?
I believe webpack should be able to handle this use case.
Other relevant information: webpack version: 5.36.0 Node.js version: 15.11.0 Operating System: MacOS 10.15.7
Issue Analytics
- State:
- Created 2 years ago
- Reactions:1
- Comments:5 (3 by maintainers)
Top Results From Across the Web
Using await outside of an async function - Stack Overflow
This I hoped would await to results, so I can use inLobby to conditionally run countPlayer , however I received a typeerror with...
Read more >How to use await outside of an async function in JavaScript
There are multiple ways to use the `await` operator outside of an `async` function - use a Node.js version higher than `16.12.0`, load...
Read more >How to use await outside of an async function in JavaScript
First, the important thing to note down here is that there is no direct way possible to use await outside of the async-function,...
Read more >Cannot use keyword await outside an async function <script ...
Checklist I have tried restarting my IDE and the issue persists. I have read the FAQ and my problem is not listed.
Read more >Module parse failed: Cannot use keyword 'await' outside an ...
I set my tsconfig.json to use "es2017" for await. It's still not compiling. Have no idea how to configure Web3Modal to a Button....
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
Fixed https://github.com/acornjs/acorn/issues/1030, please update deps
Awesome turnaround time - thank you!