Nextjs build fails on Docker due to env amid SKIP_ENV_VALIDATION

Hey, I'm building an app with nodemailer inside the nextjs app and trying to build it with docker. The docker build is failing on build stage due to env parameters. I run with the SKIP_ENV_VALIDATION parameter. here is the log output
#16 46.35 TypeError: Cannot set properties of undefined (setting 'mailer')
#16 46.35 at new Mail (/app/node_modules/nodemailer/lib/mailer/index.js:45:33)
#16 46.35 at module.exports.createTransport (/app/node_modules/nodemailer/lib/nodemailer.js:53:14)
#16 46.35 at /app/.next/server/chunks/3367.js:5293:71
#16 46.35 TypeError: Cannot set properties of undefined (setting 'mailer')
#16 46.35 at new Mail (/app/node_modules/nodemailer/lib/mailer/index.js:45:33)
#16 46.35 at module.exports.createTransport (/app/node_modules/nodemailer/lib/nodemailer.js:53:14)
#16 46.35 at /app/.next/server/chunks/3367.js:5293:71
here is the code I initialize nodemailer
import nodemailer from "nodemailer";
import { env } from "~/env.mjs";

export const transporter = nodemailer.createTransport(env.EMAIL_SERVER, {
secure: true,
});
import nodemailer from "nodemailer";
import { env } from "~/env.mjs";

export const transporter = nodemailer.createTransport(env.EMAIL_SERVER, {
secure: true,
});
Why and how does building stage of next app checks the issues with env? How to solve it?
1 Reply
parapheen
parapheen12mo ago
so, the issue seems to be related to the way next "collects pages" during the build https://github.com/vercel/next.js/discussions/35534
GitHub
What is "collecting page data" and how to turn it off? · vercel nex...
I am running next build for my app, but I don't have a database running or even an .env.production file on this machine. I am not using statically generated pages so I expect that this shouldn&...
Want results from more Discord servers?
Add your server