Error: Failed to lookup view in Express Error: Failed to lookup view in Express express express

Error: Failed to lookup view in Express


Adding to @mihai's answer:

If you are in Windows, then just concatenating __dirname' + '../public' will result in wrong directory name (For example: c:\dev\app\module../public).

Instead use path, which will work irrespective of the OS:

var path = require ('path');app.use(express.static(path.join(__dirname + '../public')));

path.join will normalize the path separator character and will return correct path value.


npm install express@2.5.9 installs the previous version, if it helps.

I know in 3.x the view layout mechanic was removed, but this might not be your problem. Also replace express.createServer() with express()

Update:

It's your __dirname from environment.js
It should be:

app.use(express.static(__dirname + '../public'));


It is solved by adding the following code in app.js file

app.engine('html', require('ejs').renderFile);app.set('view engine', 'html');app.set('views', __dirname);app.get('/', function(req, res){    res.render("index");});