How to run Node.js app with ES2017 features enabled on Heroku?

前端 未结 2 1830
执笔经年
执笔经年 2020-12-11 04:05

I\'m new to Node and created an app that has some async/await syntax in it like so:

const express = require(\'express\');
const app = express();

const someL         


        
相关标签:
2条回答
  • 2020-12-11 04:22

    Specify the node version you want to use in your package.json: https://devcenter.heroku.com/articles/nodejs-support#specifying-a-node-js-version

    So for async/await support you'll want to specify >= 7.6.0

    {
      "engines": {
        "node": ">= 7.6.0"
      }
    }
    
    0 讨论(0)
  • 2020-12-11 04:34

    From the Heroku documentation here

    https://devcenter.heroku.com/articles/getting-started-with-nodejs#declare-app-dependencies

    it should be declared in your package.json file which engine(s) should be accessible:

    {
      "name": "node-js-getting-started",
      "version": "0.2.5",
      ...
      "engines": {
        "node": "5.9.1"
      },
      "dependencies": {
        "ejs": "2.4.1",
        "express": "4.13.3"
      },
      ...
    }
    
    0 讨论(0)
提交回复
热议问题