Building Nextjs with `NODE_ENV=development` fails everytime

If I set NODE_ENV=production everything works perfectly fine. The nextjs app is built and deployed, as it should be. However, if i simply set NODE_ENV=development, the build process always fails. In fact, it fails to build every single route/path in the nextjs project. Every route faces 2 errors:

  1. Error: NextRouter was not mounted. https://nextjs.org/docs/messages/next-router-not-mounted
  2. Error occurred prerendering page "[INSERT_FAILED_PATH_HERE]". Read more: https://nextjs.org/docs/messages/prerender-error

Can someone help me understand why this is happening? and what I can do about this issue.

Hi,

There will always be differences between environments: development mode/Local, production mode/Render, etc. These differences need to be considered and configured as required for your own app in each environment.

The errors you shared have links to the NextJS docs, maybe that will point you in the right direction about the issue?

It’s also not usually advisable to run a Render service in a development mode, which often requires more resources for things like hot-reloading, on-the-fly compilation, etc. Use development mode locally, and production mode when deploying to Render.

1 Like

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