Node.js Mailer issue

Make sure that you don’t upload the node_modules folder from your computer to the server, if there is a node_modules folder delete it first before starting npm install. Run npm install from the cpanel environment if it is available there.

1 Like

my experience… … from PHP to NODE… and back to PHP… if you don’t need REALTIME data… with Sockets… then just stick to good old faithful php…

Node is great… dont get me wrong… i could see the benefits of templating and so on… but i was limited regarding servers (in my case) … and and… and costs … ect ect and limited to cloud hosting with data centers with hudge latency issues… :frowning:

But everything you can do with node you can do with php … but not sockets realtime data…

What I did on cloud hosting (node) for your mailer issues… just use an external SMTP host for handling the mail… eg sendgrid or something…

Hi @Heather_Mann ,

It looks like the error is related to the nodemailer module not being found, despite being listed in the package.json file and present in the mail.js file on the server. There could be a few reasons why this is happening.

  • First, please check if nodemailer is installed and included as a dependency in the package.json file. You can do this by running npm list nodemailer in the terminal. If it’s not installed, please run npm install nodemailer --save to add it as a dependency.

  • Another potential issue could be related to running the app from the wrong directory. Ensure that you’re running the app from the correct directory.

  • If nodemailer is installed globally, try installing it locally instead. Run “npm uninstall -g nodemailer” to remove the global installation, then run npm install nodemailer --save to install it locally in the app’s node_modules folder.

  • Lastly, if the above solutions don’t work, you can try deleting the node_modules folder and reinstalling all dependencies with npm install.

I hope this helps you resolve the issue.

I think the files are set up correctly?

Hey - Thanks for the suggestions.

Nodemailer is installed…

I believe app is in the correct place - see response to Ben.

I deleted the global nodemailer install and installed local but that didn’t fix the problem.

I also deleted the node_modules folder and reinstalled. Unfortunately that didn’t work either.

Did you check if there are any errors in the path where this module is called? In general, such problems are caused by a simple reason that is always overlooked.

Structure looks exactly as it should Heather, I was concerned the error was due to a path issue but i guess not

Brian

Thanks for trying! I might just need to use an external mail service, or go back to PHP.

Like you, I was sceptical about moving to node BUT it really is a great move.
How far down the project are you?
Could you recreate your server I case it’s a server config issue.
Have you tried a new site to see if its caused by some corruption?
I really recommend you stick with node although I understand business pressures may dictate you have to go in another direction.

Hey Patrick,

I’ll give this a try. Just want to be clear I should delete the nodes_modules folder on the server, then run npm install again from the server. Yes? And once that’s done if all is well should I download that folder from the server to local so it’s all in sync?

Thanks

It’s my own project so other than a hypothetical deadline there’s no one breathing down my neck either way. I did envisage having live chat eventually which was one of the major reasons for porting to node. I’ll keep at it for now and will try your suggestions. Thanks.

I went ahead and just renamed the nodes_modules folder and ran npm install. Same errors…

npm WARN ERESOLVE overriding peer dependencynpm WARN While resolving: ws @8 .11 .0 npm WARN Found: utf - 8 - validate @6 .0 .2 npm WARN node_modules / utf - 8 - validatenpm WARN utf - 8 - validate @ “^6.0.2”
from the root projectnpm WARN npm WARN Could not resolve dependency: npm WARN peerOptional utf - 8 - validate @ “^5.0.2”
from ws @8 .11 .0 npm WARN node_modules / wsnpm WARN ws @ “~8.11.0”
from engine.io @6 .4 .0 npm WARN node_modules / engine.ionpm WARN 1 more(socket.io - adapter) npm WARN npm WARN Conflicting peer dependency: utf - 8 - validate @5 .0 .10 npm WARN node_modules / utf - 8 - validatenpm WARN peerOptional utf - 8 - validate @ “^5.0.2”
from ws @8 .11 .0 npm WARN node_modules / wsnpm WARN ws @ “~8.11.0”
from engine.io @6 .4 .0 npm WARN node_modules / engine.ionpm WARN 1 more(socket.io - adapter) npm ERR!code 1n pm ERR!path / home / wwwtrip / nodevenv / app / 16 / lib / node_modules / bufferutilnpm ERR!command failednpm ERR!command sh / tmp / install - 22 b6337e.shnpm ERR!node: internal / child_process: 413n pm ERR!
throw errnoException(err, ‘spawn’);
npm ERR! ^ npm ERR!npm ERR!Error: spawn ENOMEMnpm ERR!at ChildProcess.spawn(node: internal / child_process: 413: 11) npm ERR!at spawn(node: child_process: 713: 9) npm ERR!at Object.execFile(node: child_process: 329: 17) npm ERR!at Object.exec(node: child_process: 226: 25) npm ERR!at Object.(/home/wwwtrip / nodevenv / app / 16 / lib / node_modules / node - gyp - build / bin.js: 8: 8) npm ERR!at Module._compile(node: internal / modules / cjs / loader: 1126: 14) npm ERR!at Object.Module._extensions…js(node: internal / modules / cjs / loader: 1180: 10) npm ERR!at Module.load(node: internal / modules / cjs / loader: 1004: 32) npm ERR!at Function.Module._load(node: internal / modules / cjs / loader: 839: 12) npm ERR!at Function.executeUserEntryPoint[as runMain](node: internal / modules / run_main: 81: 12) {
npm ERR!errno: -12, npm ERR!code: ‘ENOMEM’, npm ERR!syscall: ‘spawn’
npm ERR!
}
npm ERR!A complete log of this run can be found in: npm ERR!/home/wwwtrip / .npm / _logs / 2023 - 02 - 16 T21_38_51_356Z - debug - 0. log

“And once that’s done if all is well should I download that folder from the server to local so it’s all in sync?”

No, once recreated on server that’s enough.
Node libraries are platform specific so not interchangeable.
Your server should install compatible libraries for your server platform, Wappler will add compatible files for your development platform. They are NOT interchangeable, the library folder should never be uploaded or downloaded.

mmmm… all looks good as Brian pointed out…
Can I suggest you try it on a different hosting providers platform? eg digital ocean …
As it might be your hosting…

Copy that. Thanks.

I’m going to try a clean install on a different domain on my current host to see if that works. If not, then it may well be my host. Thanks.

I got this working!! The problem was in the mail setup in Wappler I was using localhost. I changed that to mail.triptakers.com and voila!

Thanks for all the help guys!

4 Likes