localhost:3000 未渲染节点教程
localhost:3000 is not rendering the node tutorial
我目前正在学习 thinkster MEAN 教程 - 实际上才刚刚开始学习堆栈。我白天忙于建设,一切都很好。回到家的那一刻,我运行什么也做不了。使用 npm start 时,我可以使用 curl GET 命令通过 API 层获取文档,构建本身不会呈现,我得到 404。见下文:
> Not Found 404 Error: Not Found at
> C:\Users\user\Documents\Stuff\misc\AngularTutorial\MEAN-Chapterized\flapper-news\app.js:37:13
> at Layer.handle [as handle_request]
> (C:\Users\user\Documents\Stuff\misc\AngularTutorial\MEAN-Chapterized\flapper-news\node_modules\express\lib\router\layer.js:95:5)
> at trim_prefix
> (C:\Users\user\Documents\Stuff\misc\AngularTutorial\MEAN-Chapterized\flapper-news\node_modules\express\lib\router\index.js:312:13)
> at
> C:\Users\user\Documents\Stuff\misc\AngularTutorial\MEAN-Chapterized\flapper-news\node_modules\express\lib\router\index.js:280:7
> at Function.process_params
> (C:\Users\user\Documents\Stuff\misc\AngularTutorial\MEAN-Chapterized\flapper-news\node_modules\express\lib\router\index.js:330:12)
> at next
> (C:\Users\user\Documents\Stuff\misc\AngularTutorial\MEAN-Chapterized\flapper-news\node_modules\express\lib\router\index.js:271:10)
> at
> C:\Users\user\Documents\Stuff\misc\AngularTutorial\MEAN-Chapterized\flapper-news\node_modules\express\lib\router\index.js:618:15
> at next
> (C:\Users\user\Documents\Stuff\misc\AngularTutorial\MEAN-Chapterized\flapper-news\node_modules\express\lib\router\index.js:256:14)
> at Function.handle
> (C:\Users\user\Documents\Stuff\misc\AngularTutorial\MEAN-Chapterized\flapper-news\node_modules\express\lib\router\index.js:176:3)
> at router
> (C:\Users\user\Documents\Stuff\misc\AngularTutorial\MEAN-Chapterized\flapper-news\node_modules\express\lib\router\index.js:46:12)
> at Layer.handle [as handle_request]
> (C:\Users\user\Documents\Stuff\misc\AngularTutorial\MEAN-Chapterized\flapper-news\node_modules\express\lib\router\layer.js:95:5)
> at trim_prefix
> (C:\Users\user\Documents\Stuff\misc\AngularTutorial\MEAN-Chapterized\flapper-news\node_modules\express\lib\router\index.js:312:13)
> at
> C:\Users\user\Documents\Stuff\misc\AngularTutorial\MEAN-Chapterized\flapper-news\node_modules\express\lib\router\index.js:280:7
> at Function.process_params
> (C:\Users\user\Documents\Stuff\misc\AngularTutorial\MEAN-Chapterized\flapper-news\node_modules\express\lib\router\index.js:330:12)
> at next
> (C:\Users\user\Documents\Stuff\misc\AngularTutorial\MEAN-Chapterized\flapper-news\node_modules\express\lib\router\index.js:271:10)
> at SendStream.error
> (C:\Users\user\Documents\Stuff\misc\AngularTutorial\MEAN-Chapterized\flapper-news\node_modules\serve-static\index.js:121:7)
最近构建的 git 仓库在这里:https://github.com/Rainer88/MEAN-Chapterized.git
如果您能指出正确的方向,我们将不胜感激。
GET /home
为什么是 404?
您的 index.js
on routes 文件夹没有 GET
on /home
的任何配置。因此你得到了 404
。同样,您也没有在 /
上为 GET
配置路由。
GET /
你也会得到一个 404
。因此,您需要为这些端点配置路由
router.get('/home', function (req, res) {
res.send({
msg: 'hello world from /home'
});
});
router.get('/', function (req, res) {
res.send({
msg: 'hello world from at /'
});
});
我目前正在学习 thinkster MEAN 教程 - 实际上才刚刚开始学习堆栈。我白天忙于建设,一切都很好。回到家的那一刻,我运行什么也做不了。使用 npm start 时,我可以使用 curl GET 命令通过 API 层获取文档,构建本身不会呈现,我得到 404。见下文:
> Not Found 404 Error: Not Found at
> C:\Users\user\Documents\Stuff\misc\AngularTutorial\MEAN-Chapterized\flapper-news\app.js:37:13
> at Layer.handle [as handle_request]
> (C:\Users\user\Documents\Stuff\misc\AngularTutorial\MEAN-Chapterized\flapper-news\node_modules\express\lib\router\layer.js:95:5)
> at trim_prefix
> (C:\Users\user\Documents\Stuff\misc\AngularTutorial\MEAN-Chapterized\flapper-news\node_modules\express\lib\router\index.js:312:13)
> at
> C:\Users\user\Documents\Stuff\misc\AngularTutorial\MEAN-Chapterized\flapper-news\node_modules\express\lib\router\index.js:280:7
> at Function.process_params
> (C:\Users\user\Documents\Stuff\misc\AngularTutorial\MEAN-Chapterized\flapper-news\node_modules\express\lib\router\index.js:330:12)
> at next
> (C:\Users\user\Documents\Stuff\misc\AngularTutorial\MEAN-Chapterized\flapper-news\node_modules\express\lib\router\index.js:271:10)
> at
> C:\Users\user\Documents\Stuff\misc\AngularTutorial\MEAN-Chapterized\flapper-news\node_modules\express\lib\router\index.js:618:15
> at next
> (C:\Users\user\Documents\Stuff\misc\AngularTutorial\MEAN-Chapterized\flapper-news\node_modules\express\lib\router\index.js:256:14)
> at Function.handle
> (C:\Users\user\Documents\Stuff\misc\AngularTutorial\MEAN-Chapterized\flapper-news\node_modules\express\lib\router\index.js:176:3)
> at router
> (C:\Users\user\Documents\Stuff\misc\AngularTutorial\MEAN-Chapterized\flapper-news\node_modules\express\lib\router\index.js:46:12)
> at Layer.handle [as handle_request]
> (C:\Users\user\Documents\Stuff\misc\AngularTutorial\MEAN-Chapterized\flapper-news\node_modules\express\lib\router\layer.js:95:5)
> at trim_prefix
> (C:\Users\user\Documents\Stuff\misc\AngularTutorial\MEAN-Chapterized\flapper-news\node_modules\express\lib\router\index.js:312:13)
> at
> C:\Users\user\Documents\Stuff\misc\AngularTutorial\MEAN-Chapterized\flapper-news\node_modules\express\lib\router\index.js:280:7
> at Function.process_params
> (C:\Users\user\Documents\Stuff\misc\AngularTutorial\MEAN-Chapterized\flapper-news\node_modules\express\lib\router\index.js:330:12)
> at next
> (C:\Users\user\Documents\Stuff\misc\AngularTutorial\MEAN-Chapterized\flapper-news\node_modules\express\lib\router\index.js:271:10)
> at SendStream.error
> (C:\Users\user\Documents\Stuff\misc\AngularTutorial\MEAN-Chapterized\flapper-news\node_modules\serve-static\index.js:121:7)
最近构建的 git 仓库在这里:https://github.com/Rainer88/MEAN-Chapterized.git
如果您能指出正确的方向,我们将不胜感激。
GET /home
为什么是 404?
您的 index.js
on routes 文件夹没有 GET
on /home
的任何配置。因此你得到了 404
。同样,您也没有在 /
上为 GET
配置路由。
GET /
你也会得到一个 404
。因此,您需要为这些端点配置路由
router.get('/home', function (req, res) {
res.send({
msg: 'hello world from /home'
});
});
router.get('/', function (req, res) {
res.send({
msg: 'hello world from at /'
});
});