mihett05
mihett05

Reputation: 51

Next.js production fails but dev works

I had tried to run Next.js project with next start(next build was ok and it works with next dev) and saw some error messages in browser console:

TypeError: e is undefined
Error: Minified React error #130; visit https://reactjs.org/docs/error-decoder.html?invariant=130&args[]=undefined&args[]= for the full message or use the non-minified dev environment for full errors and additional helpful warnings.
Error: Minified React error #130; visit https://reactjs.org/docs/error-decoder.html?invariant=130&args[]=undefined&args[]= for the full message or use the non-minified dev environment for full errors and additional helpful warnings.
Error rendering page:  TypeError: t is undefined

I've watched that link in error message and it says:

Element type is invalid: expected a string (for built-in components) or a class/function (for composite components) but got: [missing argument].[missing argument]

But I still don't understand where is the problem. Is there a way to disable code minification in next build and view a full traceback?

Upvotes: 2

Views: 6818

Answers (1)

user16435030
user16435030

Reputation:

  • The reason why it's doing that in prod and not dev is because nextjs will only check types on a production build (as far as I'm aware).
  • I think I've seen that error before when you pass a string or an invalid value to renderToString from react-dom/server.

The reason that's most likely happening is because nextjs will by default import all your exports and render the page for you, so in this case I don't believe you can just export named or default exports at will, I think it has to be a default export for the page component itself, while all the getStaticProps and other exports should be named.

To fix your issue just change export Example to export default Example.

Upvotes: 3

Related Questions