This is a NextJS project that reproduces this bug.
To reproduce:
npm install npm run dev # You can now visit http://localhost:3000/email-media in your browser # and notice that the page renders # # However... # This will fail: npm build