Follow

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use
Contact

cant find module koa router

import Koa from "koa"
import Router from "koa-router"
import logger from "koa-logger"
import json from "koa-json"

const app = new Koa()
const router = new Router()

router.get("/",async(ctx: any,next: any)=>{
    ctx.body = {
        meg:"Hello world"
    }
    await next
})

app.use(logger())
app.use(json())
app.use(router.routes()).use(router.allowedMethods())

app.listen(3000,()=>console.log("app is running at 3000"))

Actually,before this ,when I run npm run build,I got error src/index.ts:2:20 – error TS2307: Cannot find module ‘koa-router’. I write koa-router.d.ts myself, but I don’t think it’s a great idea, How do you guys resolve?

>Solution :

MEDevel.com: Open-source for Healthcare and Education

Collecting and validating open-source software for healthcare, education, enterprise, development, medical imaging, medical records, and digital pathology.

Visit Medevel

You say you wrote koa-router.d.ts yourself, but npm shows that the koa-router module has type declarations.

Remove koa-router and re-install it (and its types) using
npm uninstall koa-router;
npm install koa-router @types/koa-router;

Add a comment

Leave a Reply

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use

Discover more from Dev solutions

Subscribe now to keep reading and get access to the full archive.

Continue reading