Error: Cannot find module 'koa-router'
Error: Cannot find module 'koa-router'
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 发布文章使用:只允许注册用户才可以访问!
本文首发于博客园,作者:xgqfrms,原文链接:https://www.cnblogs.com/xgqfrms/p/13748596.html
未经授权禁止转载,违者必究!