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…
@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.