Tôi có một ứng dụng rất đơn giản, chỉ cần bắt đầu để có được bàn tay của tôi bẩn với nodemailer. Khi tôi chạy ứng dụng, tôi nhận được lỗi trong chính mô đun đó.Lỗi Nodemailer Không thể sửa
app.js:
const nodemailer = require('nodemailer');
const transporter = nodemailer.createTransport('smtps://me%40gmail.com:[email protected]');
var mailOptions = {
from: '"Me" <[email protected]>', // sender address
to: '[email protected], [email protected]', // list of receivers
subject: 'Hello dude', // Subject line
text: 'Test email with text', // plaintext body
html: "Testing 1..2..7" // html body
};
// send mail with defined transport object
transporter.sendMail(mailOptions, function (error, info) {
if (error) {
return console.log(error);
}
console.log('Message sent: ' + info.response);
});
Và tôi nhận được lỗi này:
C:\Users\Andrew\desktop\messy4\node_modules\nodemailer\lib\mailer\index.js:31
compile: [(...args) => this._convertDataImages(...args)],
^^^
SyntaxError: Unexpected token ...
at exports.runInThisContext (vm.js:53:16)
at Module._compile (module.js:387:25)
at Object.Module._extensions..js (module.js:422:10)
at Module.load (module.js:357:32)
at Function.Module._load (module.js:314:12)
at Module.require (module.js:367:17)
at require (internal/module.js:16:19)
at Object.<anonymous> (C:\Users\Andrew\desktop\messy4\node_modules\nodemailer\lib\nodemailer.js:3:16)
at Module._compile (module.js:413:34)
at Object.Module._extensions..js (module.js:422:10)
Thực sự không chắc chắn những gì đang happenning đây.
Người dùng Linux có thể phải sử dụng lệnh 'nodejs --version' để kiểm tra phiên bản của họ. – ThisClark
Tuyệt vời, đó là vấn đề. Cảm ơn nhiều!! –
Để nâng cấp nodejs lên v8.x: $ curl -sL https://deb.nodesource.com/setup_8.x | sudo -E bash - $ sudo apt-get install -y nodejs – Pei