Failed to lookup view “error” in views directory

青春壹個敷衍的年華 提交于 2021-02-11 13:23:59

问题


Failed to lookup view "error" in views directory

Here is my code:

app.set('views', path.join(__dirname, 'views'));
app.set('view engine', 'ejs');
console.log("set views")
// uncomment after placing your favicon in /public
//app.use(favicon(path.join(__dirname, 'public', 'favicon.ico')));
app.use(logger('dev'));
app.use(bodyParser.json());
app.use(bodyParser.urlencoded({ extended: false }));
app.use(cookieParser());
app.use(express.static(path.join(__dirname, 'public')));

回答1:


You can solve it by simply setting the views directly

app.set('views', 



回答2:


it will be :

app.set('view engine', 'ejs')

app.set('views', path.join(__dirname + '/views'))


来源:https://stackoverflow.com/questions/50480227/failed-to-lookup-view-error-in-views-directory

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!