因此,我正在遵循本指南MEAN STACK GUIDE
我在2号上遇到错误
由于我是研究均值堆栈的新手,所以我自己无法修复
这里有什么帮助吗?
这是完整的错误
Error: No default engine was specified and no extension was provided.
at new View (/Users/angelocolmenares/Desktop/Carwash/mean-secure/node_modules/express/lib/view.js:61:11)
at Function.render (/Users/angelocolmenares/Desktop/Carwash/mean-secure/node_modules/express/lib/application.js:570:12)
at ServerResponse.render (/Users/angelocolmenares/Desktop/Carwash/mean-secure/node_modules/express/lib/response.js:1008:7)
at /Users/angelocolmenares/Desktop/Carwash/mean-secure/app.js:32:7
at Layer.handle_error (/Users/angelocolmenares/Desktop/Carwash/mean-secure/node_modules/express/lib/router/layer.js:71:5)
at trim_prefix (/Users/angelocolmenares/Desktop/Carwash/mean-secure/node_modules/express/lib/router/index.js:315:13)
at /Users/angelocolmenares/Desktop/Carwash/mean-secure/node_modules/express/lib/router/index.js:284:7
at Function.process_params (/Users/angelocolmenares/Desktop/Carwash/mean-secure/node_modules/express/lib/router/index.js:335:12)
at next (/Users/angelocolmenares/Desktop/Carwash/mean-secure/node_modules/express/lib/router/index.js:275:10)
at /Users/angelocolmenares/Desktop/Carwash/mean-secure/app.js:21:3
GET /favicon.ico 404 1.584 ms - 1428
Error: No default engine was specified and no extension was provided.
at new View (/Users/angelocolmenares/Desktop/Carwash/mean-secure/node_modules/express/lib/view.js:61:11)
at Function.render (/Users/angelocolmenares/Desktop/Carwash/mean-secure/node_modules/express/lib/application.js:570:12)
at ServerResponse.render (/Users/angelocolmenares/Desktop/Carwash/mean-secure/node_modules/express/lib/response.js:1008:7)
at /Users/angelocolmenares/Desktop/Carwash/mean-secure/app.js:32:7
at Layer.handle_error (/Users/angelocolmenares/Desktop/Carwash/mean-secure/node_modules/express/lib/router/layer.js:71:5)
at trim_prefix (/Users/angelocolmenares/Desktop/Carwash/mean-secure/node_modules/express/lib/router/index.js:315:13)
at /Users/angelocolmenares/Desktop/Carwash/mean-secure/node_modules/express/lib/router/index.js:284:7
at Function.process_params (/Users/angelocolmenares/Desktop/Carwash/mean-secure/node_modules/express/lib/router/index.js:335:12)
at next (/Users/angelocolmenares/Desktop/Carwash/mean-secure/node_modules/express/lib/router/index.js:275:10)
at /Users/angelocolmenares/Desktop/Carwash/mean-secure/app.js:21:3
GET / 404 0.999 ms - 1428
Error: No default engine was specified and no extension was provided.
at new View (/Users/angelocolmenares/Desktop/Carwash/mean-secure/node_modules/express/lib/view.js:61:11)
at Function.render (/Users/angelocolmenares/Desktop/Carwash/mean-secure/node_modules/express/lib/application.js:570:12)
at ServerResponse.render (/Users/angelocolmenares/Desktop/Carwash/mean-secure/node_modules/express/lib/response.js:1008:7)
at /Users/angelocolmenares/Desktop/Carwash/mean-secure/app.js:32:7
at Layer.handle_error (/Users/angelocolmenares/Desktop/Carwash/mean-secure/node_modules/express/lib/router/layer.js:71:5)
at trim_prefix (/Users/angelocolmenares/Desktop/Carwash/mean-secure/node_modules/express/lib/router/index.js:315:13)
at /Users/angelocolmenares/Desktop/Carwash/mean-secure/node_modules/express/lib/router/index.js:284:7
at Function.process_params (/Users/angelocolmenares/Desktop/Carwash/mean-secure/node_modules/express/lib/router/index.js:335:12)
at next (/Users/angelocolmenares/Desktop/Carwash/mean-secure/node_modules/express/lib/router/index.js:275:10)
at /Users/angelocolmenares/Desktop/Carwash/mean-secure/app.js:21:3
答案 0 :(得分:0)
您尚未在routes/api.js
中定义任何路由。因此,目前您有localhost:3000/api
,这是唯一可访问的路由。
另外,由于No default engine was specified and no extension was provided.
中的第31行,您遇到app.js
错误,因为您想在点击localhost:3000/api/profile
时呈现错误页面。您没有与此路线匹配的路线。您可以将这些行更改为:
// error handler
app.use(function(err, req, res, next) {
// set locals, only providing error in development
res.locals.message = err.message;
res.locals.error = req.app.get('env') === 'development' ? err : {};
// render the error page
res.status(err.status || 500)
res.send({ 'error': 'no route found!' });
});
有关快速阅读中的render
的更多详细信息,请参见documentation