Fail to looked up view in views directory when deploy app to heroku

I've deployed my NodeJS app to Heroku and get this error: Internal Server Error. Then I look up the logs and find that Error: Failed to lookup view "student.ejs" in views directory "/app/views". My directory structure is:

  /node_modules
  /public
  /views
      student.ejs
  app.js
  packet.json

here is the versions of dependencies I used.

 "body-parser": "^1.17.2",
 "ejs": "^2.5.7",
 "express": "^4.15.3",
 "mongoose": "^4.10.2"

set up template engine and directory of view

 app.engine('html',require('ejs').renderFile);
 app.set('view engine', 'ejs')
 app.set('views',__dirname+'/views');

render

 res.render('student.ejs',{info:data});

The app can run well in localhost. Can somebody help me to solve this problem. Thank in advance!

0 Comment

NO COMMENTS

LEAVE A REPLY

Captcha image