用帕格和快递查看错误

时间:2018-06-11 17:19:12

标签: node.js express pug templating-engine

我试图将模板引擎&Pug'添加到一个带节点的简单快速服务器应用程序中,并继续获取:

Error: Failed to lookup view "index" in views directory "./views"
    at Function.render (/Users/jc.almonte/Documents/MoshCourses/NodeJs/express-demo/node_modules/express/lib/application.js:580:17)
    at ServerResponse.render (/Users/jc.almonte/Documents/MoshCourses/NodeJs/express-demo/node_modules/express/lib/response.js:1008:7)
    at app.get (/Users/jc.almonte/Documents/MoshCourses/NodeJs/express-demo/index.js:46:9)
    at Layer.handle [as handle_request] (/Users/jc.almonte/Documents/MoshCourses/NodeJs/express-demo/node_modules/express/lib/router/layer.js:95:5)
    at next (/Users/jc.almonte/Documents/MoshCourses/NodeJs/express-demo/node_modules/express/lib/router/route.js:137:13)
    at Route.dispatch (/Users/jc.almonte/Documents/MoshCourses/NodeJs/express-demo/node_modules/express/lib/router/route.js:112:3)
    at Layer.handle [as handle_request] (/Users/jc.almonte/Documents/MoshCourses/NodeJs/express-demo/node_modules/express/lib/router/layer.js:95:5)
    at /Users/jc.almonte/Documents/MoshCourses/NodeJs/express-demo/node_modules/express/lib/router/index.js:281:22
    at Function.process_params (/Users/jc.almonte/Documents/MoshCourses/NodeJs/express-demo/node_modules/express/lib/router/index.js:335:12)
    at next (/Users/jc.almonte/Documents/MoshCourses/NodeJs/express-demo/node_modules/express/lib/router/index.js:275:10)

我用谷歌搜索,但未能找到解决方案。这是我的文件结构和帕格文件的图片:

pug file structure

代码及以下是我用来尝试渲染模板的代码:

app.set('view engine', 'pug'); 
app.set('views', './views')

从我的package.json下面是express和pug的版本:

"express": "^4.16.3",
"pug": "^2.0.3"

0 个答案:

没有答案