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

Install the plugin locally:
npm install -D @netlify/plugin-nextjs@4.37.4

And then add this to your netlify.toml file (or create it in your root):

  package = "@netlify/plugin-nextjs"

You will also need the pre-build hack given by lewisking in this thread.

thanks for sharing this with the community

Hello Support Team / Community,

I have tried pre-build step shared by @lewisking but still getting this error frequently. See full error below

I have also verified that pre-build step has ran during build process. Please suggest what am I missing.

Jun 30, 08:49:57 PM: 4a9f27b4 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
    at new NodeError (node:internal/errors:387:5)
    at throwExportsNotFound (node:internal/modules/esm/resolve:365:9)
    at packageExportsResolve (node:internal/modules/esm/resolve:649:3)
    at resolveExports (node:internal/modules/cjs/loader:554:36)
    at Function.Module._findPath (node:internal/modules/cjs/loader:594:31)
    at Function.Module._resolveFilename (node:internal/modules/cjs/loader:1012:27)
    at /var/task/.netlify/functions-internal/___netlify-handler/requireHooks.js:91:40
    at Function.Module._load (node:internal/modules/cjs/loader:871:27)
    at Module.require (node:internal/modules/cjs/loader:1098:19)
    at require (node:internal/modules/cjs/helpers:108:18) {

Hi @kunal.saxena.kunal , thanks for reaching out.

Are you using the latest of the react-dom package? Have you tried clearing your yarn and npm cache? If you have done all these things you can remove the node_modules from your project and reinstall the dependencies.

I hope this helps!

I am using latest version of react-dom 18.2.0. I have tried building with

npm cache clean --force && npm run build

but still seeing this error.

Can you all try v4.39.0: @netlify/plugin-nextjs - npm ( and see if it helps? It’s currently only available on npm and rolling out to some sites gradually. If you wish to use it now, please manually upgrade, or wait till your site gets the update.


Just tried with 4.39.0 but get the same error again [ERR_PACKAGE_PATH_NOT_EXPORTED]: Package subpath './server.edge' is not defined by "exports" in /var/task/node_modules/react-dom/package.json at new NodeError (node:internal/errors:387:5)

Thank you for trying. It’s interesting to know, this should have fixed it as it appeared to do so in our tests. I’ve asked the devs to check again. Apologies for the back-n-forth.

Hey @dreieinsvier,

Would you be able to provide a reproduction of your site?


I’m also still having this issue.

Site id: c56c18c0-42da-47bb-a9bc-bea9b2129c1f

"@netlify/plugin-nextjs": "^4.39.0"

"next": "^13.4.9"

I’ve also tried ISR and SSR and both handlers end up giving the same error.

I have the same issue. 500 Internal Error, but not in all requests, just in a few.

"@netlify/plugin-nextjs": "^4.39.0"
"next": "^13.4.7"

The issue has been reproduced on our end and we’re working towards a solution.


@hrishikesh any updates so far?

Mind trying v4.39.1: Release plugin-nextjs: v4.39.1 · netlify/next-runtime ( We now switched to Next.js’ in-built way of detecting app router, so it should work for all use-cases. But let us know if it still fails.

I’m afraid v4.39.1 still has the same 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

It’s kind of true - when you look at the package.json, it doesn’t have server.edge exported:

"exports": {
    ".": "./index.js",
    "./client": "./client.js",
    "./server": {
      "deno": "./server.browser.js",
      "worker": "./server.browser.js",
      "browser": "./server.browser.js",
      "default": "./server.node.js"
    "./server.browser": "./server.browser.js",
    "./server.node": "./server.node.js",
    "./profiling": "./profiling.js",
    "./test-utils": "./test-utils.js",
    "./package.json": "./package.json"

What site did you test this on? I’m checking the site you mentioned and it keeps giving me a 404.

EDIT: Nevermind, noticed that it was in a sub-directory.

@nick.howard would it be possible to share your repo?

I don’t think so, as it’s work I’m doing for a company, but I can share what breaks it.

I’m using a Prismic CMS and the @primicio/client package. It uses the native fetch under the hood, which is the fetch provided by NextJS in this instance.

When I call fetch without any next options, it works fine, since it’s generating static content. The problem comes when I provide the following options:

fetchOptions: {
  next: {
    revalidate: 60 * 60,

The idea is that I want it to revalidate the content in an hour. In this instance, I see the error in the ISR Handler function.

I’ve also tried

fetchOptions: {
  cache: 'no-cache'

Which will never cache the response. In this instance, I see the error in the SSR Handler function.

I can also see server.edge is exported in the main branch of react-dom

But maybe the haven’t released it :person_shrugging:

Thanks for sharing. I’ve relayed that back to the devs!

1 Like

No problem. My thinking is that it’s not a Netlify-specific issue, and actually something that needs picking up with NextJS or the React team