question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Module parse failed: The keyword 'yield' is reserved

See original GitHub issue

What version of Next.js are you using?

12.0.4

What version of Node.js are you using?

16.13.0

What browser are you using?

NA

What operating system are you using?

macOS

How are you deploying your application?

NA

Describe the Bug

npm run build fails with the following error:

Module parse failed: The keyword 'yield' is reserved (453:107)
File was processed with these loaders:
 * ./node_modules/next/dist/build/webpack/loaders/next-swc-loader.js
You may need an additional loader to handle the result of these loaders.

when looked closely at the code, there is an await call which is converted to as yield throwing an error.

Not sure why this is throwing as an error.

Expected Behavior

Build should pass.

To Reproduce

Write a function with async/await.

Run npm run build.

Issue Analytics

  • State:closed
  • Created 2 years ago
  • Reactions:16
  • Comments:14 (7 by maintainers)

github_iconTop GitHub Comments

3reactions
timneutkenscommented, Nov 19, 2021

Can you try again? There was a publishing issue with npm

3reactions
jfobrien29commented, Nov 17, 2021

+1 Seeing the same issue. This code uses an await and is replaced by yield when compiled. Issue presented going from next.js 12.0.1 -> 12.0.4

info  - Creating an optimized production build  
Failed to compile.

./src/containers/BoardBuilder/Blocks/AvailableOnePagers.tsx
Module parse failed: The keyword 'yield' is reserved (249:47)
File was processed with these loaders:
 * ./node_modules/next/dist/build/webpack/loaders/next-swc-loader.js
You may need an additional loader to handle the result of these loaders.
|                                 var ref;
|                                 // eslint-disable-next-line no-await-in-loop
>                                 var response = yield axios.post(routes.boardOnePagerAdd(boardUuid, slug), {
|                                 }, {
|                                     headers: generateHeaders()

Import trace for requested module:

Here’s the code before it’s compiled

try {
          // eslint-disable-next-line no-await-in-loop
          const response = await axios.post(
            routes.boardOnePagerAdd(boardUuid, slug),
            {},
            { headers: generateHeaders() },
          )
Read more comments on GitHub >

github_iconTop Results From Across the Web

"The keyword yield is reserved" eslint error - Stack Overflow
I'm attempting to use Webpack 1.13.12 and eslint 3.11.0 and eslint-plugin-promise 3.4.0. I'm trying to use the answer in this question to get ......
Read more >
SyntaxError: The keyword 'yield' is reserved. Console Error in ...
I'm trying Nakama, a great game server for realtime multiplayer, and most of their Javascript client example code includes the use of ...
Read more >
Javascript – “The keyword yield is reserved” eslint error
When I attempt to lint this, eslint complains that The keyword 'yield' is reserved. I've tried setting require-yield to 0 in my ....
Read more >
the keyword 'yield is reserved react native - Code Grepper
The keyword 'yield' is reserved ... // try to add `await` to function if not there already.
Read more >
ES6 doesn't need opt-in - ES Discuss
For example, if let as a keyword breaks the web, then in global code we treat it as an ... yield reserved in...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found