Error: Cannot find module 'styled-jsx/style'

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

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?

Hi @jmarroyave,

I find a similar thread from a few weeks ago:

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"

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

oh that’s awesome! thanks for writing in and sharing that bit.