1

I am trying to deploy a simple app on heroku. App is using Express js.

I am facing problem when I use let keyword in the code. The heroku app page shows the application error image. When I convert let to var the same page works.

I am unable to understand that. let keyword works fine on my desktop but not on heroku.

Please help if there is any solution.

This code is not working due to let

app.post('/adduser',(req,res) => {
    let userdata = req.body.data;
});
raju
  • 6,448
  • 24
  • 80
  • 163

1 Answers1

2

let is a relatively new javascript feature. It was made available to Node starting in version 4. It sounds like you a running an old version of Node on your Heroku server.

This should be a relatively easy fix assuming upgrading doesn't break any existing code:

From Heroku's docs:

Use the engines section of your package.json to specify the version of Node.js to use on Heroku. Drop the ā€˜v’ to save only the version number:

{
  "name": "myapp",
  "description": "a really cool app",
  "version": "1.0.0",
  "engines": {
    "node": "6.11.1"
  }
}
Mark
  • 90,562
  • 7
  • 108
  • 148