Email &引用;名称“;[1] :--缺少--在hapi v17.4.0中启动服务器时出错
我正在开发一个hapi应用程序,我想通过向用户发送电子邮件来实现忘记密码逻辑。为此,我使用了一个插件hapi mail来使用AWS的SES服务发送电子邮件。我得到一个错误:Email &引用;名称“;[1] :--缺少--在hapi v17.4.0中启动服务器时出错,email,hapijs,reset-password,Email,Hapijs,Reset Password,我正在开发一个hapi应用程序,我想通过向用户发送电子邮件来实现忘记密码逻辑。为此,我使用了一个插件hapi mail来使用AWS的SES服务发送电子邮件。我得到一个错误: "name" [1]: -- missing -- }, "options": { "template": { "engine": "handlebars", "path": "./templates/" }, "email": { "engine": "s
"name" [1]: -- missing --
},
"options": {
"template": {
"engine": "handlebars",
"path": "./templates/"
},
"email": {
"engine": "ses",
"options": {
"region": "eu-west-1"
},
"defaultFrom": "abc@gmail.com"
}
}
}
[1] "name" is required
at new AssertionError (internal/errors.js:469:11)
at Object.exports.assert (/home/Utkarsh_Jaiswal/Documents/node-hapi-app/node-hapi-app/node_modules/hoek/lib/index.js:736:11)
at Object.exports.apply (/home/Utkarsh_Jaiswal/Documents/node-hapi-app/node-hapi-app/node_modules/hapi/lib/config.js:22:10)
at internals.Server.register (/home/Utkarsh_Jaiswal/Documents/node-hapi-app/node-hapi-app/node_modules/hapi/lib/server.js:392:31)
at process._tickCallback (internal/process/next_tick.js:68:7)
at Function.Module.runMain (internal/modules/cjs/loader.js:721:11)
at startup (internal/bootstrap/node.js:228:19)
at bootstrapNodeJSCore (internal/bootstrap/node.js:576:3)
(node:8069) UnhandledPromiseRejectionWarning: Unhandled promise rejection. This error originated either by throwing inside of an async function without a catch block, or by rejecting a promise which was not handled with .catch(). (rejection id: 1)
(node:8069) [DEP0018] DeprecationWarning: Unhandled promise rejections are deprecated. In the future, promise rejections that arenot handled will terminate the Node.js process with a non-zero exit code.
以下是用于定义选项并向服务器注册插件的代码段:
const options = {
template: {
engine: 'handlebars',
path: './templates/'
},
email: {
engine: 'ses',
options: { accessKeyId: access_key, secretAccessKey: secret_key, region: 'eu-west-1' },
defaultFrom: 'abc@gmail.com'
}
};
await server.register([{
plugin: require('hapi-mail'),
options: options
}]);
如何解决此错误?还有更好的方法来实现这个想法。除了我正在使用的方法之外,应该采用什么方法来处理此问题?您尝试使用的插件适用于较旧版本的Hapi。它要求版本15符合
package.json
您正在使用的Hapi的第17版,用于说明如何注册与旧版Hapi不向后兼容的插件
您需要找到支持Hapi 17的其他邮件插件,或者降级以使用Hapi 15,但我不推荐后者。您能提供替代Hapi邮件的其他插件的链接吗??