Open kcrwfrd opened 2 weeks ago
It turns out this is actually caused by the same issue described here: https://github.com/vercel/next.js/issues/56481#issuecomment-1755369676
I had the following in my ~/.zshrc
export NODE_ENV="development"
So, to update the steps to reproduce:
NODE_ENV=development npm run build
There is a warning that gets printed and links to https://nextjs.org/docs/messages/non-standard-node-env, but it is confusing because development
is a valid value.
Link to the code that reproduces this issue
https://github.com/kcrwfrd/next.js-pages-build-error-reproduction
To Reproduce
Then I added a
useRouter()
call to mypages/index.tsx
.(fwiw just a fresh
reproduction-template-pages
template already suffered some of these errors you see, but adding theuseRouter()
call reproduced the sameError: NextRouter was not mounted
error that I was trying to troubleshoot in my original app).Current vs. Expected behavior
Static pages are expected to successfully build, but they are failing.
Provide environment information
Which area(s) are affected? (Select all that apply)
Pages Router
Which stage(s) are affected? (Select all that apply)
next build (local)
Additional context
No response