vercel / next.js

The React Framework
https://nextjs.org
MIT License
125.89k stars 26.86k forks source link

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

Open jmarroyave-compsci opened 1 year ago

jmarroyave-compsci commented 1 year ago

Link to the code that reproduces this issue

https://github.com/jmarroyave-compsci/error-nextjs-netlify-styled-jsx

To Reproduce

  1. When deploying a build to netlify after upgrading Next.js from 12.3.4 to 13.5.5
  2. When trying to fetch an api handler from the browser it shows the error ( /pages/api folder )
  3. Happens also in versions: 13.5.5-canary.8, 13.5.4, 13.5.3, 13.0.0

Current vs. Expected behavior

Expect to fetch data from API's handler but instead shows the errror

Verify canary release

Provide environment information

Binaries:
  Node: v16.20.0
  npm: 8.19.4

Which area(s) are affected? (Select all that apply)

Middleware / Edge (API routes, runtime)

Additional context

What I tried?

Installing different plugin versions ( @netlify/plugin-nextjs )
Installing different nextjs versions
Deleting node_modules and package-lock.json and reinstalling everything again
npm i -S styled-jsx
wadehammes commented 11 months ago

I don't understand why this gets no response from Next team. Ive had an issue open with similar things happening on API routes since the release of 13.5 on Sept. 20.

vLX42 commented 11 months ago

In our project we had a old hack related to an issues with [...slug]

App.getInitialProps = async ({ router: _ }) => {
   //hack to get router.asPath to work with [...slug], with out this it don't return the url but only the acutal url inside next.js
   return {
     props: {}, // will be passed to the page component as props
   }
 }

Removing this fixed it in our case, so maybe you should have look if you have any getInitialProps etc that could cause it.

wadehammes commented 11 months ago

In our project we had a old hack related to an issues with [...slug]

App.getInitialProps = async ({ router: _ }) => {
   //hack to get router.asPath to work with [...slug], with out this it don't return the url but only the acutal url inside next.js
   return {
     props: {}, // will be passed to the page component as props
   }
 }

Removing this fixed it in our case, so maybe you should have look if you have any getInitialProps etc that could cause it.

image

Pages work fine, this is specifically with API routes for me ^

jmarroyave-compsci commented 11 months ago

I confirm it is solved in version 14.0.1