Next.js 14.2.0 - Your target environment does not appear to support 'async/await' #64410
Replies: 5 comments 1 reply
-
Having this exact same issue! Any solution? |
Beta Was this translation helpful? Give feedback.
-
tsconfig
next.config
Still the same warning pops up with Next 14.2.x while everything is perfectly fine with 14.1.x |
Beta Was this translation helpful? Give feedback.
-
Having the same issue, even in a newly started project. Simply adding a top level await to a project using |
Beta Was this translation helpful? Give feedback.
-
I have this warning when I use server component in client component |
Beta Was this translation helpful? Give feedback.
-
Probably its related to Edge runtime + middleware / instrumentation.ts / external libs. Edge runtime is a vercel thing. Middlewares have to be run on it. Not all node features are supported there (including top level await) and not all libs will work. There are discussions about allowing users to use nodejs runtime instead (1, 2, 3). (Sidenote: issue is not related to tsconfigs target probably. Not sure but webpack may not consider that target when builds your app at all.) === In my case I called func inside instrumentation.ts. That func uses prisma (and inits it if not yet) and produces log entries like yours (about not supported top level async await). Placing that func in app route (just for testing) does not produce log warns. So i wrapped that function like this (according to docs):
And log warning dissapears. In case you face such problem in middleware I assume this will not work as only edge runtime available there. |
Beta Was this translation helpful? Give feedback.
Uh oh!
There was an error while loading. Please reload this page.
-
Summary
After updating from 14.1.4 to 14.2.0, I'm getting this warning during build time for every page that has a top-level await:
It doesn't stop the build or affect the page rendering, but just wanted to know what's causing this and how can I fix the issue that's generating this warning.
I saw that this warning was also identified here: #61551
Additional information
Example
No response
Beta Was this translation helpful? Give feedback.
All reactions