Importing/exporting the Express router using ES6 import + export keywords and Babel

后端 未结 2 736
粉色の甜心
粉色の甜心 2021-02-07 08:07

I have an old test project originally built with Express 2.X. I am moving it to Express 4.x and trying to insert Babel 6.x to experiment with ES6 features server-side.

T

2条回答
  •  离开以前
    2021-02-07 08:26

    The problem is that you are exporting router as named export router, but trying to import it as indexRoute.

    You should either rename your export:

    export { router as indexRoute }
    

    or change your import:

    import { router as indexRoute } from './routes/index_route';
    

提交回复
热议问题