Hey I'm trying to debug an error that's comming up with rendering a .jade page with node.js and ExpressJS.
The error is: Error: Failed to lookup view "/workspace/friends" in views directory "C:\Users\Utilizador\Documents\GitHub\QuantBull-Project\views".
So what are the reasons for occurring this error. I'm asking this because supposedly it should be working fine, at least it does with the other files...
I created a the following GET listener, located at controller/workspace.js to render the file:
/**
* GET /workspace/friends
*/
app.get('/workspace/friends', function (req, res) {
res.render('/workspace/friends', {
url: '/workspace'
});
});
and the file called friends.jade is located under views/workspace.
So I was wondering what can originate this error? Because this situation looks different compared to the other situations with the same error message I found on SO and others...
I think I figured out, problem is here.
use below
res.render('workspace/friends')
instead of
res.render('/workspace/friends')
When you say res.render('somefolder/file) so it searches in views/someolder/file. Because you are saying res.render('/somefolder/somefile) so it should be getting confused with /.