Express Js Error Failed To Locate View Layout
Contents |
here for a quick overview of the site Help Center Detailed answers to any questions you might failed to lookup view error in views directory express have Meta Discuss the workings and policies of this site About
Failed To Lookup View Error In Views Directory Ejs
Us Learn more about Stack Overflow the company Business Learn more about hiring developers or posting ads
Failed To Lookup View Error In Views Directory Node Js
with us Stack Overflow Questions Jobs Documentation Tags Users Badges Ask Question x Dismiss Join the Stack Overflow Community Stack Overflow is a community of 4.7 million programmers,
Failed To Lookup View Index Ejs In Views Directory
just like you, helping each other. Join them; it only takes a minute: Sign up NodeJS + Express + Handlebars - failed to locate view “index.html” up vote 14 down vote favorite 3 I have been playing a bit with Node.js. I recently started toying with Express and have been setting up a basic app. error failed to lookup view index in views directory /app/views I wanted to use Handlebars as my view templating engine, but am hitting a wall - failed to locate view "index.html" I have index.html in the same directory as app.js and and so I would think the code below would have no problem locating index.html... I have searched around, but it would seem that comprehensive examples of anything aside from jade are rare... Anyone have experience with this combo? Thanks in advance! var express = require('express') , app = express.createServer(); app.configure(function(){ app.set('view engine', 'handlebars'); app.set("view options", { layout: false }) }); app.get('/', function(req, res){ var data = { name: "Ford Prefect", home: "a small planet somewhere in the vicinity of Betelgeuse" } res.render('index.html', data); }); app.listen(3000); Update: I was missing: app.set('views', __dirname + '/'); app.register('.html', require('handlebars')); in my config... it would seem that the register of '.html' is quite important as it specifies the handlebars association with .html... I hope this helps someone... Because I am a SO noob, I can't answer my own question
here for a quick overview of the site Help Center Detailed answers to any questions you might have Meta Discuss the workings failed to lookup view in views directory ejs and policies of this site About Us Learn more about Stack Overflow failed to lookup view index in views directory ghost the company Business Learn more about hiring developers or posting ads with us Stack Overflow Questions Jobs Documentation this.engine is not a function Tags Users Badges Ask Question x Dismiss Join the Stack Overflow Community Stack Overflow is a community of 4.7 million programmers, just like you, helping each other. Join them; it http://stackoverflow.com/questions/8814437/nodejs-express-handlebars-failed-to-locate-view-index-html only takes a minute: Sign up “failed to locate view layout, tried…” up vote 0 down vote favorite My Node.js app is configured as such: app.configure(function() { app.set('views', __dirname + '/views'); app.set('view engine', 'ejs'); //etc. }); My views folder only contains index.ejs and I don't want to use layouts now. However I am getting: failed to locate view "layout", tried: http://stackoverflow.com/questions/35386887/failed-to-locate-view-layout-tried - /Users/stephane/code/node/project/views/layout.ejs Why? node.js express share|improve this question asked Feb 14 at 0:11 Stéphane Bruckert 10.8k54077 add a comment| 1 Answer 1 active oldest votes up vote 0 down vote accepted There is an option to specify that we don't want to use layouts within the view: app.set('view options', { layout: false }); share|improve this answer answered Feb 14 at 0:11 Stéphane Bruckert 10.8k54077 add a comment| Your Answer draft saved draft discarded Sign up or log in Sign up using Google Sign up using Facebook Sign up using Email and Password Post as a guest Name Email Post as a guest Name Email discard By posting your answer, you agree to the privacy policy and terms of service. Not the answer you're looking for? Browse other questions tagged node.js express or ask your own question. asked 8 months ago viewed 91 times active 8 months ago Related 14NodeJS + Express + Handlebars - failed to locate view “index.html”27Multiple View paths on Node.js + Express0Displaying views in Node.js/Express0How to render view and layout for homepage?3How to use p
von GoogleAnmeldenAusgeblendete FelderNach Gruppen oder Nachrichten suchen
at ServerResponse.res._render (/home/pc/project/mongooseLearning/node_modules/express/lib/view.js:417:18) at ServerResponse.res.render (/home/pc/project/mongooseLearning/node_modules/express/lib/view.js:318:17) at ServerResponse.res._render (/home/pc/project/mongooseLearning/node_modules/express/lib/view.js:432:10) at ServerResponse.res.render (/home/pc/project/mongooseLearning/node_modules/express/lib/view.js:318:17) at /home/pc/project/mongooseLearning/app.js:47:7 at callbacks (/home/pc/project/mongooseLearning/node_modules/express/lib/router/index.js:272:11) at param (/home/pc/project/mongooseLearning/node_modules/express/lib/router/index.js:246:11) at pass (/home/pc/project/mongooseLearning/node_modules/express/lib/router/index.js:253:5) at Router._dispatch (/home/pc/project/mongooseLearning/node_modules/express/lib/router/index.js:280:5) 这是我项目的截图。我从始至终的文件里都没有写layout,但是它却要去找layout文件,让我很想不明白,这是为什么? 分享即可 +1积分 0 提问者 勇恒的思念 添加回答 回答 1回答 2015-12-22 qq_神话_6 加油,加油,加油---2016 你写html页面元素是完整的吗?会不会你没有写头元素之类的? 取消 保存 赞同 反对 0个回复 未知生物 你还没有登录,请先登录或注册慕课网帐号 回复 我要提问 相关问题 js代码问题求解,按照慕课的写着怎么就有报错呢?2 回答 老师上课敲得代码在哪可以下载?3 回答 node.js能开发大型网站吗?3 回答 最近在学习Nodejs,在网页端往MongoDB插入数据时出现如下错误,如何解决呢?2 回答 http不是无状态协议吗?为什么能有长轮询和http流这种持续链接的comet方法?3 回答 相关分类 Node.js 7485人关注 关注 node传到前端的值无法读取的问题? 1 回答 我对nginx不是很明白 1 回答 取消 提交 网站首页 企业合作 人才招聘 联系我们 合作专区 关于我们 讲师招募 意见反馈 友情链接 Copyright © 2016 imooc.com All Rights Reserved | 京ICP备 13046642