require('babel/register') doesn't work

前端 未结 8 1278
春和景丽
春和景丽 2020-12-01 07:01

I have isomorphic app written in ES6 on client with Babel transpiler. I want my express server to have the same ES6 syntax as client code.

Unfortunately requi

8条回答
  •  北荒
    北荒 (楼主)
    2020-12-01 07:40

    require('babel/register') doesn't transpile the file it is called from. If you want server.js to be included in on-the-fly transpilation, you should execute it with babel-node (Babel's CLI replacement for node).

    See my answer here for an example.

提交回复
热议问题