Error Failed To Locate View Layout
Contents |
Sign in Pricing Blog Support Search GitHub This repository Watch 1,552 Star 27,801 Fork 5,142 expressjs/express Code Issues 89 Pull requests 37 Projects 0 Wiki fatal error failed to locate Pulse Graphs New issue Error: failed to locate view "layout" #720 Closed
Fatal Error Failed To Locate Necessary
codesplicer opened this Issue Jun 22, 2011 · 11 comments Projects None yet Labels bug Milestone failed to lookup view in views directory No milestone Assignees No one assigned 2 participants codesplicer commented Jun 22, 2011 Just updated express and keep getting this error when directory layout is like: views frontend room index.jade express handlebars layout-room.jade and my view function is: res.render('frontend/room/index', {
layout: 'layout-room'
}); This was working fine until I updated, if that helps. expressjs member tj commented Jun 22, 2011 you shouldn't need to specify "/index", res.render('frontend/room') should work, that might resolve the layout issue expressjs member tj commented Jun 22, 2011 also note that by default if layout.ENGINE is defined in the same dir as the rendered view it should be automatically selected by default so maybe try removing the layout option and renaming it to layout.jade codesplicer commented Jun 22, 2011 I tried that, but still get the following in the console: failed to locate view "layout", tried: /Users/vik/local_repository/myapp/views/layout.jade /Users/vik/local_repository/myapp/views/_layout.jade /Users/vik/local_repository/myapp/views/layout/index.jade It doesn't seem to be following the path down correctly, but its wierd because this code has been working fine until I updated express. expressjs member tj commented Jun 22, 2011 hmm do you know which version you were on before updating? that might help track down the change. codesplicer commented Jun 22, 2011 2.3.10 expressjs member tj commented Jun 22, 2011 very odd, not much changed in 2.3.11 just some express(1) stuff codesplicer commented Jun 22, 2011 hmm. Very odd. Guess I need to restructure my views directory. expressjs member tj commented Jun 22, 2011 weird I just tried with HEAD and it works for me with: views/ users/ layout.jade index.jade for res.render('users') expressjs member tj commented Jun 22, 2011 hmm it does seem broken when you explicitly pass
here for a quick overview of the site Help Center Detailed answers to any questions you might have Meta Discuss the workings and policies of this site About Us Learn more about Stack Overflow the company Business Learn more about hiring developers or posting ads with us Stack Overflow Questions Jobs Documentation Tags Users Badges Ask Question x Dismiss Join the Stack Overflow Community Stack https://github.com/expressjs/express/issues/720 Overflow is a community of 4.7 million programmers, just like you, helping each other. Join them; it only takes a minute: Sign up Error: Failed to lookup view in Express up vote 25 down vote favorite 4 Note: my auto answer at end of the post I'm trying to make a better http://stackoverflow.com/questions/10216395/error-failed-to-lookup-view-in-express experience of nodeJS and i don't really like to get all the script in one file. so, following a post here i use this structure ./ config/ enviroment.js routes.js public/ css/ styles.css images views index index.jade section index.jade layout.jade app.js My files are right now: app.js var express = require('express'); var app = module.exports = express.createServer(); require('./config/enviroment.js')(app, express); require('./config/routes.js')(app); app.listen(3000); enviroment.js module.exports = function(app, express) { app.configure(function() { app.use(express.logger()); app.use(express.static(__dirname + '/public')); app.set('views', __dirname + '/views'); app.set('view engine', 'jade'); //extension of views }); //development configuration app.configure('development', function() { app.use(express.errorHandler({ dumpExceptions: true, showStack: true })); }); //production configuration app.configure('production', function() { app.use(express.errorHandler()); }); }; routes.js module.exports = function(app) { app.get(['/','/index', '/inicio'], function(req, res) { res.render('index/index'); }); app.get('/test', function(req, res) { //res.render('index/index'); }); }; layout.jade !!! 5 html head link(rel='stylesheet', href='/css/style.css') title Express + Jade body #main h1 Content goes here #container!= body index/index.jade h1 algoa The error i get is: Error: Failed to lookup view
here for a quick http://stackoverflow.com/questions/13067792/routes-and-views overview of the site Help Center Detailed answers to any questions you might have Meta Discuss the workings and policies of this site About Us Learn more about Stack Overflow the company Business Learn more about hiring developers or posting ads failed to 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, just like you, helping each other. Join them; it only takes a minute: Sign error failed to up routes and views up vote 1 down vote favorite I am using nodejs with express. On a get-request to the root path I want to route to an index file. If there is a get-request to the path "/game" I want to route to a different source. app.get('/', function(req, res){ res.render( "index", {locals : { myLocal : "myValue"}} ); }); app.get('/game', function(req, res){ res.render("/game/index", {locals : { myLocal : "myValue"}} ); }); The first "get" works nice but the second sends this exception: 500 Error: failed to locate view "/game/index" at Function.exports.compile (D:\Webstorm\myExpress\node_modules\express\lib\view.js:61:15) at ServerResponse.res._render (D:\Webstorm\myExpress\node_modules\express\lib\view.js:417:18) at ServerResponse.res.render (D:\Webstorm\myExpress\node_modules\express\lib\view.js:318:17) at exports.game (D:\Webstorm\myExpress\routes\index.js:12:9) at callbacks (D:\Webstorm\myExpress\node_modules\express\lib\router\index.js:272:11) at param (D:\Webstorm\myExpress\node_modules\express\lib\router\index.js:246:11) at pass (D:\Webstorm\myExpress\node_modules\express\lib\router\index.js:253:5) at Router._dispatch (D:\Webstorm\myExpress\node_modules\express\lib\router\index.js:280:5) at Object.middleware [as handle] (D:\Webstorm\myExpress\node_modules\express\lib\router\index.js:45:10) at next (D:\Webstorm\myExpress\node_modules\express\