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

前端 未结 8 1257
春和景丽
春和景丽 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:55

    Since Babel 7 use, you can use @babel/register

    npm install --save-dev @babel/core @babel/register
    

    or

    yarn add --dev @babel/core @babel/register
    

    if you're using yarn.

    In the code you just include the following line:

    require("@babel/register");
    

提交回复
热议问题