xgqfrms™, xgqfrms® : xgqfrms's offical website of cnblogs! xgqfrms™, xgqfrms® : xgqfrms's offical website of GitHub!

Error: Cannot find module 'koa-router'

Error: Cannot find module 'koa-router'

image

koa-router !== koa-route

# ✅ install OK 👍
$ yarn add koa-router   

https://www.npmjs.com/package/koa-router

# ❌ install by mistake 👎
$ yarn add koa-route

https://www.npmjs.com/package/koa-route

koa-route 👎💩❌

$ yarn add koa-route
# OR
$ npmi koa-route

const log = console.log;

const fs = require('fs');

const koa = require('koa');
const router = require('koa-router');
const app = new koa();
// const app = koa();

const routers = router();
routers.get('/things/:name/:id', sendIdAndName);

function *sendIdAndName(){
  this.body = 'id: ' + this.params.id + ' and name: ' + this.params.name;
};

app.use(routers.routes());
app.listen(3000);

https://www.tutorialspoint.com/koajs/koajs_url_building.htm

refs



©xgqfrms 2012-2020

www.cnblogs.com 发布文章使用:只允许注册用户才可以访问!


posted @ 2020-09-29 11:02  xgqfrms  阅读(1895)  评论(2编辑  收藏  举报