koajs / router

Router middleware for Koa. Maintained by @forwardemail and @ladjs.

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

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

knockkk opened this issue · comments

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:

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

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