无法从任何提供程序nodemailer aws加载凭据

我一直在努力寻找一个解决我的问题一段时间。 我一直在尝试使用nodemailer和nodemailer-ses-transport。 这里是nodemailer代码:

var cfg = require('../config/config'); var nodemailer = require('nodemailer'); var aws = require('nodemailer-ses-transport'); var transporter = nodemailer.createTransport(aws({ accessKeyId: cfg.KEY, secretAccessKey: cfg.SKEY, default_region: cfg.REG, ratelimit: 5 })); router.post('/signup', function(req, res, next){ passport.authenticate('local.signup', function(err, user, info) { if (err) { return next(err); } // Redirect if it fails if (!user) { return res.redirect('/signup'); } req.logIn(user, function(err) { if (err) { return next(err); } // Redirect and send email if it succeeds var date = Date.now(); var mailOptions = { from: cfg.USER, to: req.body.email, date: date, subject: 'Welcome to Shapevibe', html: '<p> Welcome to Shapevibe!</p>' }; transporter.sendMail(mailOptions, function(error, info){ if(error){ console.log(error); } else{ console.log('Message Sent: ' + info); } }); return res.redirect('/api/dashboard/viber' + user._id); }); // flash success and redirect to viber dashboard req.flash('success', 'Thank you for signing up. You will recieve an email shortly'); })(req, res, next); }); 

在configuration文件里面:

 var config = {}; config.USER = 'Shapevibe@gmail.com'; config.KEY = 'xxxxxxxxxxx'; config.SKEY = 'xxxxx'; config.REG = 'us-west-2c'; module.exports = config; 

当我运行npm start时,它连接到服务器正常。 但是,当我testing第一页的符号时,路由工作正常,但电子邮件不发送,我得到这个错误:

 { CredentialsError: Missing credentials in config at IncomingMessage.<anonymous> (/home/ubuntu/ShapeVibe/Website/node_modules/aws-sdk/lib/util.js:864:34) at emitNone (events.js:91:20) at IncomingMessage.emit (events.js:188:7) at endReadableNT (_stream_readable.js:975:12) at _combinedTickCallback (internal/process/next_tick.js:80:11) at process._tickDomainCallback (internal/process/next_tick.js:128:9) message: 'Missing credentials in config', retryable: false, time: 2017-08-09T19:13:54.105Z, code: 'CredentialsError', originalError: { message: 'Could not load credentials from any providers', retryable: false, time: 2017-08-09T19:13:54.105Z, code: 'CredentialsError' } } I have been researching a solution for a long time now, and nothing has seemed to work. I looked at almost everything similar on Stackoverflow and nothing has helped. Please let me know if you have any ideas.