While trying to upgrade Next.js from 12.3.4 to 13.5.5.
It happens with the api’s handlers ( /pages/api folder )
This is the repo and this is the live site
file: src/pages/api/test.js
export default function handler( req, res) {
res.status(200).json({ message: 'Hello from Next.js!' })
}
Only happens in production, it works fine in dev mode. I’m hosting this build in netlify and using the pluggin @netlify /plugin-nextjs, it works fine with version 4.37.4 ( next 12.3.4 ) .
What I tried?
Installing different plugin versions ( @netlify/plugin-nextjs )
* 4.38.0
* 4.38.1
* 4.40.2
Installing different nextjs versions
* 13.5.5-canary.8
* 13.5.4
* 13.5.3
* 13.4.19
* 13.0.0
Deleting node_modules and package-lock.json and reinstalling everything again
npm i -S styled-jsx
Thanks in advance
1 Like
fool
October 16, 2023, 4:56pm
2
Hey there! Could you try a nextjs version 13.4.x? I think that will work around this error.
Hi, already did it, any other idea? or do you know why is this happening? it’s netlify or nextjs issue?
Melvin
October 18, 2023, 12:56pm
4
Hi @jmarroyave ,
I find a similar thread from a few weeks ago:
I am also getting errors on both 13.4 and 13.5
On 13.5 I am getting the error in the title of the thread.
On 13.4 I am getting a 500 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
This reproduction repo is pretty much a vanilla create-next-app with Typescript and Tailwind options selected.
Anything statically rendered works fine but the SSR stuff all fails, including the not-found page…
Do any of the solutions mentioned there work for you?
Hi Melvin, also tried this combination of packages and didn’t work
"next": "^13.4.9",
"@netlify/plugin-nextjs": "^4.40.2"
Melvin
October 18, 2023, 3:33pm
6
Hi @jmarroyave ,
Could you try removing the ^
so that you’re just using the following in your package.json:
"next": "13.4.9",
"@netlify/plugin-nextjs": "4.40.2"
I think what may be happen with the ^
in there it’s being updated to the latest version.
I don’t get you, when is it upgrading it or where?
Forget it, I found where, thanks.
I confirmed that pacakges with versions:
next": "13.4.9",
"@netlify/plugin-nextjs": "4.40.2"
works as a workaround.
Do you have any advice for solving the issue?
No advice at the moment. It’ll be solved at a later date.
With the latest version of @netlify /plugin-nextjs v4.41.1
Have there been any updates to address this, or possibly a timeline when we can expect support for Next v13.5?
Also, if I’m mistaken that this issue is reliant on @netlify /plugin-nextjs please let me know. This is a bit of a black box for our team.
@jonverne1 ,
We cannot provide any definite timeline yet, but yes, this is reliant on the plugin.
I confirm that this is was solved in version
NextJS: 14.0.1
@netlify /plugin-nextjs: 4.41.1
SamO
November 2, 2023, 3:49pm
12
oh that’s awesome! thanks for writing in and sharing that bit.