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) {
code: 'ERR_PACKAGE_PATH_NOT_EXPORTED'
}
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.
Can you all try v4.39.0: @netlify/plugin-nextjs - npm (npmjs.com) 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.
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