Within my Angular project, I am attempting to utilize Nodemailer for sending emails.
The initial issue arises when I try to import (after running npm i --save) as numerous errors occur when executing ionic serve
. It's important to note that right after adding the import statement, a lengthy error log is displayed, causing the app to crash
https://i.sstatic.net/RpDn1.png
The errors mostly revolve around missing or not found modules, but why? There were no errors during the npm i --save process. Furthermore, there are no syntax errors in my code. My primary objective is to execute the sendMail()
function.
I am perplexed as to the cause of this issue. Should I consider switching from nodemail
to another option? Any suggestions would be greatly appreciated.
Error log:
Microsoft Windows [Version 10.0.19041.264]
(c) 2020 Microsoft Corporation. All rights reserved.
C:\Users\Admin\Desktop\ionic\ionic-project-1-login-and-nested-list-and-report-modal-master>ionic serve
...
The structure of my code (.ts) is fairly straightforward:
import { Component, OnInit } from '@angular/core';
import * as nodemailer from 'nodemailer';
@Component({
selector: 'app-reset-password-one',
templateUrl: './reset-password-one.page.html',
styleUrls: ['./reset-password-one.page.scss'],
})
export class ResetPasswordOnePage implements OnInit {
emailTo = '';
// create expiration date
constructor() { }
ngOnInit() {
}
sendVerification() {
// this.getToken();
this.sendMail();
}
getToken() {
//create random 16 character token
var chars = '0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ';
var token = '';
for (var i = 16; i > 0; --i) {
token += chars[Math.round(Math.random() * (chars.length - 1))];
}
console.log(token);
return token;
}
sendMail() {
...
}
}