using nodemailer in nextjs can't resolve child_process #10778
Replies: 4 comments 3 replies
-
Please provide a fully reproducing example so someone may provide assistance. |
Beta Was this translation helpful? Give feedback.
-
@Timer, just wondering if you've had time to take another look at this issue? I cannot build this app without resolving this issue first. Is there another npm emailer package better suited for NextJs applications that I can use instead? |
Beta Was this translation helpful? Give feedback.
-
Hey @Timer shouldn't Next.js automatically load server-side only modules in the |
Beta Was this translation helpful? Give feedback.
-
I had a similar issue. It seems that a generic package import, traverses all files underneath regardless of whether the methods are actually called:
Actually first goes to the root index.js inside the package and calls:
Therefore the error was triggered. Solutions are:
|
Beta Was this translation helpful? Give feedback.
-
Using nodemailer in one of the
pages/api
routes produces the following error message:[ error ] ./node_modules/nodemailer/lib/sendmail-transport/index.js Module not found: Can't resolve 'child_process' in 'C:\ua-demo\node_modules\nodemailer\lib\sendmail-transport'
With my understanding being that the next.js
pages/api
routes run in the server environment alone, it is a wonder that this error is occurring. How could this be addressed so that I can send email updates to my users?An example has been added here at codesandbox.io. I think that we need to build a copy of the program directly on a local machine to reproduce.
Also discussed on SO
Beta Was this translation helpful? Give feedback.
All reactions