gpt4 book ai didi

node.js - 无法查找 View 、更正文件名和位置

转载 作者:搜寻专家 更新时间:2023-10-31 23:32:47 25 4
gpt4 key购买 nike

我按照这里的说明操作:https://scotch.io/tutorials/easy-node-authentication-setup-and-local ,当我在尝试运行我的代码时遇到此错误,

错误:无法在 View 目录“Directory/views”中查找 View “index.ejs”

at EventEmitter.render (Directory/node_modules/express/lib/application.js:579:17)
at ServerResponse.render (Directory/node_modules/express/lib/response.js:961:7)
at Directory/ourMeanJS/config/routes.js:10:13
at Layer.handle [as handle_request] (Directory/node_modules/express/lib/router/layer.js:95:5)
at next (Directory/node_modules/express/lib/router/route.js:131:13)
at Route.dispatch (Directory/node_modules/express/lib/router/route.js:112:3)
at Layer.handle [as handle_request] (Directory/node_modules/express/lib/router/layer.js:95:5)
at Directory/node_modules/express/lib/router/index.js:277:22
at Function.process_params (Directory/node_modules/express/lib/router/index.js:330:12)
at next (Directory/node_modules/express/lib/router/index.js:271:10)
at Directory/node_modules/connect-flash/lib/flash.js:21:5
at Layer.handle [as handle_request] (Directory/node_modules/express/lib/router/layer.js:95:5)
at trim_prefix (Directory/node_modules/express/lib/router/index.js:312:13)
at Directory/node_modules/express/lib/router/index.js:280:7
at Function.process_params (Directory/node_modules/express/lib/router/index.js:330:12)
at next (Directory/node_modules/express/lib/router/index.js:271:10)

这是我的路线设置:

module.exports = function(app, passport) {

// =====================================
// HOME PAGE (with login links) ========
// =====================================
app.get('/', function(req, res) {
res.render('index.ejs'); // load the index.ejs file
});

这是我的一些 server.js:

app.set('view engine', 'ejs'); // set up ejs for templating
require('./config/routes.js')(app, passport);

我的 View 在 Directory/views 中,我有一个名为 index.ejs 的 View 。有人知道出了什么问题吗?

*edit 刚刚发现这条路线可行,不知道是不是线索

app.get('/signup', function(req, res) {

// render the page and pass in any flash data if it exists
res.render('signup.ejs', { message: req.flash('signupMessage')});
});

最佳答案

我也有这个问题,我的查找器将文件显示为 index.ejs 但它实际上是 index.ejs.html 在幕后。要在 Mac 上修复此问题,请右键单击您的文件 -> 获取信息 -> 并从中删除 .html 扩展名。

关于node.js - 无法查找 View 、更正文件名和位置,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/33890574/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com