引入npm模块后报错
发布于 5 年前 作者 yang19 11187 次浏览 来自 问答

报错信息如下:

VM860:1 thirdScriptError 

 sdk uncaught third Error 

 module “miniprogram_npm/nodemailer/events” is not defined 

 Error: module “miniprogram_npm/nodemailer/events” is not defined

    at require (http://127.0.0.1:59882/appservice/__dev__/WAService.js:1:1015979))

    at http://127.0.0.1:59882/appservice/__dev__/WAService.js:1:1015729

    at __REQUIRE__ (http://127.0.0.1:59882/appservice/miniprogram_npm/nodemailer/index.js:31:34))

    at http://127.0.0.1:59882/appservice/miniprogram_npm/nodemailer/index.js:660:12

    at Object.module.exports.map…/shared [as func] (http://127.0.0.1:59882/appservice/miniprogram_npm/nodemailer/index.js:231:24))

    at __REQUIRE__ (http://127.0.0.1:59882/appservice/miniprogram_npm/nodemailer/index.js:37:23))

    at http://127.0.0.1:59882/appservice/miniprogram_npm/nodemailer/index.js:226:12

    at Object.module.exports.map…/mailer [as func] (http://127.0.0.1:59882/appservice/miniprogram_npm/nodemailer/index.js:71:18))

    at __REQUIRE__ (http://127.0.0.1:59882/appservice/miniprogram_npm/nodemailer/index.js:37:23))

    at http://127.0.0.1:59882/appservice/miniprogram_npm/nodemailer/index.js:11430:10

console.error @ VM860:1

(anonymous) @ WAService.js:1

(anonymous) @ WAService.js:1

e @ appservice?t=1554034994106:1095

window.onerror @ VM860:1

scriptLoaded @ appservice?t=1554034994106:1127

script.onload @ appservice?t=1554034994106:1139

代码如下:

‘use strict’;

const nodemailer = require(‘nodemailer’);

// import { nodemailer } from ‘…/…/miniprogram_npm/nodemailer/index.js’

Page({

data: {

},

onLoad: function() {

},

sendEmail:function(){

var transporter = nodemailer.createTransport({

service: ‘qq’,

auth: {

user: ‘[email protected]’,

pass: ‘eqyldhtoxlfvfigc’

}

});

var mailOptions = {

from: ‘[email protected]’,

to: ‘[email protected]’,

subject: ‘Sending Email using Node.js’,

text: ‘That was easy!’

};

transporter.sendMail(mailOptions, function (error, info) {

if (error) {

console.log(error);

} else {

console.log('Email sent: ’ + info.response);

}

});

}

})

1 回复

你好,请问问题是否已解决?

回到顶部