问题
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