我的问题是,我知道 chrome 浏览器无法执行常见的 js 模块,但在节点 js 文件中,它将所有内容作为常见 js 导入,chrome 显示错误,如果我使用 ecmascript(e26) 模块导入 nodemailer,则它说不能在语句之外导入模块,所以它们是两个错误如何解决它们,或者我的技术错误插入 nodemailer 请帮助我和 thaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaanks 这是我的代码
import * as nodemailer from "nodemailer"
var a=Math.round(Math.random()*999999);
c=document.getElementById("p");
var b=c;
function otpch(){
if(document.getElementById("optcheck").value===a){
document.open();
document.write("You are successfully Logged In")
}
}
function otpm(){
alert(4236)
var mailOptions = {
from: 'mygmailid@gmail.com',
to: b,
subject: 'Your Otp',
text: 'Your onetime otp is'+a
};
alert(4236)
var transport = nodemailer.createTransport({
service: 'gmail.com',
auth: {
user:'friendsgmailid@gmail.com',
pass:'itssecret'
}
});
alert("hi123");
transport.sendMail(mailOptions,function(err,info){
if(err) {
document.getElementById("demo").innerHTML="Error while sending otp please check your gmail id which you filled is correct or not ";
} if(info){
document.getElementById("demo").innerHTML="Otp Sent Successfully";
}
});
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Document</title>
<script type="module" src="nodemailer/lib/nodemailer.js"></script>
<script src="sketch.js"></script>
</head>
<body >
<h3>Welcome to our site jain services</h3>
<h5>Write Your Gmail Address</h5>
<p id="p"><input id="gmailcheck"type="email" placeholder="Write Your Gmail" required></p>
<h4>click on the button to sign in</h4>
<button onclick="otpm()" type="submit"id="un" style="border: 3px solid black; border-radius: 50px;">Submit</button>
<h3 id="demo" style="color: red;">.</h3>
<input id="otpcheck" onclick="otpch()" type="number">
</body>
</html>