Server.edge not defined Error on nextJS SSR functions cause site to return 500 Errors

ERROR Error [ERR_PACKAGE_PATH_NOT_EXPORTED]: Package subpath ‘./server.edge’ is not defined by “exports” in /var/task/node_modules/react-dom/package.json

Deploy succesfull for site -

But nextJS SSR function returns the error above. Tried upgrading and downgrading next version, no use.
Worked just fine on my last release a few weeks ago.

Any Ideas? Thanks!

Hi @amiram,

We’ve not seen this error before. Mind sharing a minimal reproduction?

Hey @hrishikesh ,

Seems a similar issue is raised here -

although I’m not using the nx package.

Their workaround solution is to add a __next_private_prebundled_react env variable, which is not possible in netlify because it starts with an underscore? (or is there a way to set it anyway?)

I am getting the same exact issue when deploying on Netlify this repo:

It can be easily reproduced by simply forking my repo and try to deploy it on Netlify

I’m having the same issue, I even tried using Next 13.4.2. Ever since upgrading to Next 13.4, it has been happening. It seems like an issue with Next since they added a fix in one of the previous releases (13.3), but it hasn’t resolved the problem. I have provided more details about it in the next-runtime discussion, which can be found here.

Hey @amiram,

We’ve added the environment variable for your site from our end. Let us know if it works.

If others need that variable as well, please let us know the site id or subdomain and we can get it added.

Hi. Do you mind adding the variable for this site id: 842a3cc6-6d53-4d8f-85da-854ea2f433f2
I’m getting an error because “variable must start with a letter”

Hi @hrishikesh,
Do you mind adding the env var to my site as well. The siteID is f50f99c1-9959-499f-bccf-84ad47a8c51b.
I even added a Netlify Support email but looks like it will take a while. Hoping to get it done faster throug here.
Thank you.

Hi @hrishikesh Would you be able to add the variable for me as well?
The siteID is 4a52ab6f-2827-4fec-86ff-6c66b52059e6
Thank you very much

Hi @hrishikesh ,
Please add the env variable to our site also:

Site ID: f6920b29-cfac-4cbb-ac1f-3c34cabef01e

Thank you.

You can use the Netlify CLI to add this environment variable, e.g.

➜ netlify env:set __NEXT_PRIVATE_PREBUNDLED_REACT next
Set environment variable __NEXT_PRIVATE_PREBUNDLED_REACT= next in the all context on  main [✘!?] via  v18.15.0 took 3s 
➜ netlify env:list
1 environment variable for site somesite in the dev context 
|              Environment variables              |
|               Key               | Value | Scope |
? Show values? Yes
1 Like

To clarify, this should work for anyone at any account level. You may need to configure the CLI first, so this is the doc for that:

(you’ll need to have done at least netlify login and also netlify link before you can use the CLI workflow explained above.)

@sadhikari and @roberto I managed to get the variable added for your sites before Nick taught us this trick.

When you are ready for it to be removed, that will be possible through the UI :slight_smile:

1 Like

Receiving this error when using that env variable, with the deploy failing:
Invalid AWS Lambda parameters used in this request.

Confirmed it’s being set correctly and upgraded to Next.js 13.4.2 (latest). Anyone else been able to successfully deploy? Just tested over at Vercel and it works out-of-the-box (not surprisingly).


I have the same exact error. I am not adding any env variables that might clash with AWS.

There’s a pull request tracking the upgrade of Next runtime to 13.4.x here: chore: upgrade to next v13.4 by taty2010 · Pull Request #2080 · netlify/next-runtime · GitHub

From what I’ve found, this happens on any error, including automatic handling of 404s, fetch requests that don’t return 200 and manually triggering notFound() in the page component. I’ve testet this up to 13.4.2 and it always leads to 500. It’s especially annoying because it’s impossible to debug what the underlying error is right now. You can try/catch yourself and avoid the problem, but it’s really not a solution.

3:13:45 PM: Failed during stage 'building site': 
Environment variable key '__NEXT_PRIVATE_PREBUNDLED_REACT' 
must start with a letter

Was able to add the variable however the deploy fails at the initialization phase.

Hey all! We’re aware of the issues around this change with Next.js and are working to ensure Next.js continues working normally on Netlify. As soon as we have any further updates, we’ll update this thread.

1 Like

Would it be possible to have some more transparency on which version of next the netlify runtime currently supports “stable”? I feel like it’s really hard to get an answer on that and should at least be public in the runtime readme on github.

1 Like

Hi @hrishikesh

Can you add the env variable for this site aswell:
siteID: da2f62d5-0e6b-4205-9096-3f32d0ff5bd6

Thank you!

Hi, I have found quite a janky solutions but works for me.

Turns out the __NEXT_PRIVATE_PREBUNDLED_REACT environment variable might have nothing to do with build process regarding to NextJS code, it uses to override to uses Vercel’s precompiled react-dom that has ./server.edge imports on next/server runtime. Means that this variable has to be present in Lambda functions. But because of some quirks you cannot add them directly.

So, I do some patches to make react overriding to always trigger before starts any builds and my site now works normally without issues.


1 Like