这是我的代码:
import Koa from 'koa';
import convert from 'koa-convert';
import nunjucksRender from 'koa-nunjucks-render';
import nunjucks from 'nunjucks';
import path from 'path';
import serve from 'koa-static';
import views from 'koa-views';
// 路由
import homeRouter from './routers/home.router.js';
const app = new Koa();
// Must be used before any router is used
app.use(views(__dirname + 'views', {
map: {
html: 'nunjucks'
}
}));
app.use(async (ctx)=>{
await ctx.render('./index');
})
app.listen(3000, () => {
console.log('Listening on port', 3000);
})
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title></title>
</head>
<body>
index 222
</body>
</html>
我使用webpack构建app.js然后运行node build / app.js
但是投掷错误:ENOENT:没有这样的文件或目录,stat'/views/index.html'
有我的文件结构
有人可以告诉我为什么koa-views无法找到索引模板