TypeError: Class extends value #<Object> is not a constructor or null

Hi there,

can anyone help me to figure out what´s the issue with this error?

I tried to upload a Node.js and Next.js app on Heroku, but it failed because I did not add "type": "module" inside the package.json

After I added "type": "module" to package.json I needed to change the file extension from next.config.js (.js) to next.config.cjs (.cjs (commonJS)). Then I tried to run the app to see if everything works and I got the above error.

It seems that I messed up something with the node.js and the Nextjs environment…

Can anyone help?

Thank you!! :slight_smile:

I made some research and I found this discussion on Next JS Github about the issue I am facing. I tried some of these option but I couldn´t solve the error.

Actually I miss the understanding whats going on under the hood, but maybe someone else can understand it and know a possible solution for this.

If you console.log Document, what is it?

Then what does it do if you change to

import { default as Document, Html, Head, Main, NextScript } from "next/document";

??

The error I showed in the intro just occured because I changed next.config.js to next.config.cjs after I got this error message:

Then I got this error message:

document

I think this error message shows up because _document.js is linked to next.config.js and it can not find next.config.cjs. When I delete next.config.cjs I get the same error.

I console.log(Document) inside the console and I get back this:

I still get the same error.

Having the same problem, any updates?

@oAnfibio I split the project in frontend files and backend files and I decided to host the frontend application on Vercel and the backend application on Heroku, then the error no longer appeared. Actually I am not sure if this is neccessary or if there is any another solution to host both frameworks (Next.js and Node.js) within one project and on one hosting platform.

This topic was automatically closed 182 days after the last reply. New replies are no longer allowed.