本文介绍了需要时,Nodemailer错误的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我的简历网站差不多完成了,我刚刚敲定一份联系我表格,该表格应该给我发送一封带有一些纯文本的电子邮件。

My resume website is almost done, I'm just finalizing a "Contact me" form that should send me an e-mail with some plain text.

这里是它在翡翠中的样子:

Here's what it looks like in Jade:

div.contact-email-box
    form(id='contact-form' action='/' method='post')
        h3 Contact me
        div
            label
                span Name:
                input(placeholder='e.g: Mark' type='text' tabindex='1' required autofocus)
        div
            label
                span Email:
                input(placeholder='e.g: [email protected]' type='email' tabindex='2' required)
        div
            label
                span Message:
                textarea(tabindex='3' required)
        div
            button(name='Submit' type='submit' id='contact-submit') Send Email

这里是在哪里我catc h我的 server.js 中的 POST

And here's where I catch the POST in my server.js:

var express = require('express')
              , app = express()
var nodemailer = require('nodemailer')

app.post('/', function(req, res) {
})

As你可以看到它没有做任何事情,但我收到以下错误:

As you can see it does not do anything, yet I receive the following error:

SyntaxError:意外的令牌......

SyntaxError: Unexpected token ...

仅当我 require(' nodemailer')即使它已正确安装到我的 node_modules

That happens only when I require('nodemailer') even though it is installed correctly to my node_modules.

这是一个已知的bug?我该如何解决?

Is this a known bug? How may I fix it?

推荐答案

看起来像是一个节点版本问题。扩展运算符在早期版本的Node上无效,请检查以确保您运行的是支持ES6功能的版本。

Looks like a node version issue to me. The spread operator is not valid on earlier versions of Node,, check to make sure you are running a version that supports ES6 features.

这篇关于需要时,Nodemailer错误的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

08-06 11:09