Heroku Node.js应用程序在本地工作,但部署时不工作

我有一个MEAN Stack Heroku应用程序,运行得很好。 但后来我添加了一个新的function:

app.get('/userCreated/:id', function(req, res) { if (req.cookies.userCreated == req.params.id) { res.send(true); } else { res.send(false); } }); 

而现在我得到一个503(服务不可用)错误加载应用程序。 任何人都有一个想法,为什么这可能是?

我正在使用Angular和$ http.get()来访问这个Express.js函数…

编辑:这里是我的客户端angular色代码,正在打电话给服务器:

 var deferred = $q.defer(); function thisUserCreated(id) { $http.get('/userCreated/' + id).success(function(data) { deferred.resolve(data); // returns boolean indicating whether the current user has the proper cookie // saying this user created the given group }); return deferred.promise; }; 

那么,我真的明白了。 事实certificate,我没有列出我的所有依赖项在我的package.json。

这里的教训:安装节点包时总是使用–save

或者你会有一个不好的时间。

这段代码中没有任何内容被破坏。

只需检查日志,看看是什么给你的错误:

 heroku logs --tail 

尝试重新编译( ng build -prod )Angular side并再次部署。 同时观看MEAN Stack Front To Back [第10部分] – 应用程序部署到Heroku

希望能帮助到你