koajs / router

Router middleware for Koa. Maintained by @forwardemail and @ladjs.
MIT License
849 stars 174 forks source link

"new Router()" cause "router_1.default is not a constructor" error #135

Closed knockkk closed 2 years ago

knockkk commented 2 years ago

node.js version: v17.0.1

npm/yarn and version: yarn 1.22.15

@koa/router version: 10.1.1

koa version: 2.13.4

Code sample:

import Router from '@koa/router';
const router = new Router();

Expected Behavior:

no error

Actual Behavior:

TypeError: router_1.default is not a constructor

Additional steps, HTTP request details, or to reproduce the behavior or a test case:

krosenk729 commented 1 year ago

hi @knockkk what did you do to resolve this? I'm getting the same issue doing import * as KoaRouter from "@koa/router";

chamomile98 commented 1 year ago

hi @knockkk what did you do to resolve this? I'm getting the same issue doing import * as KoaRouter from "@koa/router";

if you are using typescript, try to add "esModuleInterop": true in your tsconfig.json