Next.js Discord

Discord Forum

Error disappearing after making a copy

Unanswered
Polar bear posted this in #help-forum
Open in Discord
Polar bearOP
I'm getting the good old
Warning: React.createElement: type is invalid -- expected a string (for built-in components) or a class/function (for composite components) but got: undefined. You likely forgot to export your component from the file it's defined in, or you might have mixed up default and named imports.
 ⨯ Error: Unsupported Server Component type: undefined
    at stringify (<anonymous>)

error with my NextJS 13 project using app directory. The error is being logged in the server console when I'm navigating my app, usually after three or four page compilations. I got no stack trace so I had no idea what component was being exported/imported incorrectly. Normally VS Code should hilight these in the editor, but mine showed that everything was ok. I stripped down the project to the point where I only had a root layout returning an empty html page, and I was still getting the same error.

Finally I made a copy of the project for additional debugging. Interestingly, I could not reproduce the error in the copy, everything was working as expected. Although this resolves my issue assuming it doesn't reappear, I would still like to know how is it possible that two identical sources can cause different behavior?

0 Replies