0

I downloaded from heroku website and did npm install and after running I got

SyntaxError: Unexpected token.

Note that I write a code 2 weeks ago but that not work today.

Even I tried to install different version of nodemailer but something happens.....

Any idea why? Image of error

Ali
  • 3,373
  • 5
  • 42
  • 54

3 Answers3

1

It's basically because of nodejs version. Mine was v 4.2.6 which was a bit deprecated and after upgrading it to the latest it works like a charm!

To upgrade nodejs to v8.x:

# Using Ubuntu
curl -sL https://deb.nodesource.com/setup_8.x | sudo -E bash -
sudo apt-get install -y nodejs

# Using Debian, as root
curl -sL https://deb.nodesource.com/setup_8.x | bash -
apt-get install -y nodejs
Pei
  • 11,452
  • 5
  • 41
  • 45
0

Change ...args to args on line 31

If args is not defined then just try an empty array, []

xerq
  • 2,362
  • 1
  • 9
  • 16
  • I tried to change that but, then it says change it e.g. at line 56 and then again change it on 75 line etc etc. When I all change then some other error shows up! I tried to search on google and there was bug with nodemailer, is there any alternative to nodemailer? – Haris Hamzić May 15 '17 at 18:47
  • that's not a bug, your code's syntax is just not valid – xerq May 15 '17 at 22:57
  • I think spread operator is valid, or which part do you mean? This occured on my env after updating nodemailer. – Jaakko Karhu Aug 03 '17 at 10:39
0

I know it is a old thread but for someone with the same problem maybe it may help.

In my case, I am working on c9 IDE and every time I open my workspace it changes the node version to use to 4.5.6 which not support some of the ES6 features, using nvm use 8.2.1 (or the lastest node version you have) everything starts working again.

Check that node version is the one you were using.

Hictus
  • 210
  • 2
  • 12