How to start the server with ES6 standards

前端 未结 1 1816
余生分开走
余生分开走 2021-01-28 07:59

I have a server, the code of the file index.js is shown below. I want to post it on https://dashboard.heroku.com/. But it does not start the command node inde.js.

相关标签:
1条回答
  • 2021-01-28 08:30

    The ES6 import is not yet fully supported by Node. It is still experimental. To use them, you need to change your files extension from .js to .mjs and start them with this flag :

    node --experimental-modules my-app.mjs
    

    More details there : https://nodejs.org/api/esm.html

    0 讨论(0)
提交回复
热议问题