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
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 you can see it does not do anything, yet I receive the following error:
/home/kade_c/website/node_modules/nodemailer/lib/mailer/index.js:31 pile: [(...args) => this._convertDataImages(...args)], ^^^
SyntaxError: Unexpected token ...
That happens only when I require('nodemailer')
even though it is installed correctly to my node_modules
.
Is this a known bug? How may I fix it?
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
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 you can see it does not do anything, yet I receive the following error:
/home/kade_c/website/node_modules/nodemailer/lib/mailer/index.js:31 pile: [(...args) => this._convertDataImages(...args)], ^^^
SyntaxError: Unexpected token ...
That happens only when I require('nodemailer')
even though it is installed correctly to my node_modules
.
Is this a known bug? How may I fix it?
Share Improve this question asked Feb 3, 2017 at 17:09 ChristopherChristopher 1493 silver badges11 bronze badges3 Answers
Reset to default 3Looks 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.
Node.js version 6+ is must. Check your Node version with the following mand:
node --version
If you are not at least 6+ then you must upgrade.
You may receive another error message instructing you to login to your account. In that case, go to your email inbox and you will see a message from Google with a link to a page for setting up less secure app permissions.
Nodemailer is patible with Node version 6 or above (as per https://nodemailer./about/#requirements)
So follow these steps to upgrade node:
1* sudo npm cache clean -f
2* sudo npm install -g n
3* sudo n stable
4* sudo ln -sf /usr/local/n/versions/node/5.4.1/bin/node /usr/bin/node (the bold text/version should be the one installed in during above step.)
ie if 8.1.1 is installed then do sudo ln -sf /usr/local/n/versions/node/8.1.1/bin/node /usr/bin/node
node –v (Should show updated version now)
发布者:admin,转转请注明出处:http://www.yc00.com/questions/1745413827a4626654.html
评论列表(0条)