Next.js Discord

Discord Forum

Running a built nextjs application with node gives the './server.edge' is not defined error

Answered
American Crocodile posted this in #help-forum
Open in Discord
American CrocodileOP
I'm helping someone deploy a next.js project using Node. for it to work I assume the build artifact should be able to run from node standalone.
The project is part of a NX monorepo so I grab the build artifact from there, run npm install and npm run start and I get a page with Internal Server Error and I get the ./server.edge error in console.output
I also get this error Error: Cannot find module 'next/dist/shared/lib/html-context.js'

Googling this most things I find are related to problems deploying on Vercel or Netlify and claims it is fixed with version 13.5.2

I'm using 13.5.3 and React-dom 18.2

I'm thinking that it is possible something is missing from the NX build artifact but I really need a bit of a clue of what that could be. What would cause this error?
Answered by Polar bear
I was able to get around this by deleting node_modules and the .next directory, npm run build && npm run start
View full answer

2 Replies

Polar bear
Also having this issue. Not on Netlify or Vercel either. Only seems to be affecting dynamic routes, static routes are working fine.
Polar bear
I was able to get around this by deleting node_modules and the .next directory, npm run build && npm run start
Answer