Stretch0
Stretch0

Reputation: 9251

Heroku failing to run node ES6 code

I have an express app generated with express-generator and have added in babel to transpile everything to a bin file.

I have also added in my package.json

"engines": {
  "node": ">= v8.9.0"
 }

to ensure it's running the same version of node as my local env.

For some reason, as soon as I added my service which is using es6 class syntax, the app fails to run:

export default class GifService {}

The only error I get in my logs are

2018-01-21T16:13:48.175448+00:00 heroku[router]: at=error code=H10 desc="App crashed" method=GET path="/" host=gentle-depths-57675.herokuapp.com request_id=a4c00cb7-5071-4883-a730-6355409d6aa2 fwd="86.28.187.108" dyno= connect= service= status=503 bytes= protocol=https

which isn't much help.

I am also having the same issue when I use async/await. Any one come across this before?

Thanks

Upvotes: 1

Views: 431

Answers (1)

Stretch0
Stretch0

Reputation: 9251

Looks like it was an issue with my babel presets.

I was trying to transpile to stage-2 with a bunch of plugins

old .babelrc

{
  "presets": [
    "es2015",
    "stage-2"
  ],
  "plugins": [
    "transform-runtime",
    "syntax-async-functions",
    "transform-regenerator"
  ]
}

I'm guessing this isn't supported by Heroku.

I have since changed my babel preset to the following:

new .babelrc

{
  "presets": [
    ["env", {
      "targets": {
        "node": "current"
      }
    }]
  ]
}

Upvotes: 1

Related Questions