在Heroku错误上运行Node.js应用程序

时间:2017-09-03 21:00:02

标签: javascript node.js mongodb heroku

2017-09-03T18:50:57.000000+00:00 app[api]: Build started by user 
[me]
2017-09-03T18:51:28.776809+00:00 heroku[web.1]: State changed from 
crashed to starting
2017-09-03T18:51:28.572116+00:00 app[api]: Deploy 20b0544e by user 
[me]
2017-09-03T18:51:28.572116+00:00 app[api]: Release v22 created by 
user [me]
2017-09-03T18:50:57.000000+00:00 app[api]: Build succeeded
2017-09-03T18:51:30.798246+00:00 heroku[web.1]: Starting process with 
command `node index.js`
2017-09-03T18:51:34.045108+00:00 app[web.1]: Sun, 03 Sep 2017 
18:51:34 GMT body-parser deprecated bodyParser: use individual 
json/urlencoded middlewares at index.js:95:9
2017-09-03T18:51:34.047680+00:00 app[web.1]: Sun, 03 Sep 2017 
18:51:34 GMT body-parser deprecated undefined extended: provide 
extended option at node_modules/body-parser/index.js:105:29
2017-09-03T18:51:34.050039+00:00 app[web.1]: Sun, 03 Sep 2017 
18:51:34 GMT express-session deprecated undefined resave option; 
provide resave option at index.js:111:9
2017-09-03T18:51:34.050243+00:00 app[web.1]: memory, and will not 
scale past a single process.
2017-09-03T18:51:34.142994+00:00 app[web.1]: listening on *:5000
2017-09-03T18:51:34.050242+00:00 app[web.1]: designed for a 
production environment, as it will leak
2017-09-03T18:51:34.158304+00:00 app[web.1]: failed to connect to 
server [localhost:27017] on first connect [MongoError: connect 
ECONNREFUSED 127.0.0.1:27017]
2017-09-03T18:51:34.141487+00:00 app[web.1]: (node:4) 
DeprecationWarning: `open()` is deprecated in mongoose >= 4.11.0, use 
`openUri()` instead, or set the `useMongoClient` option if using 
`connect()` or `createConnection()`. See 
http://mongoosejs.com/docs/connections.html#use-mongo-client
2017-09-03T18:51:34.050241+00:00 app[web.1]: Warning: 
connect.session() MemoryStore is not
2017-09-03T18:51:34.050168+00:00 app[web.1]: Sun, 03 Sep 2017 
18:51:34 GMT express-session deprecated undefined saveUninitialized 
option; provide saveUninitialized option at index.js:111:9
2017-09-03T18:51:34.165093+00:00 app[web.1]: 
Db.prototype.authenticate method will no longer be available in the 
next major release 3.x as MongoDB 3.6 will only allow auth against      
users in the admin db and will no longer allow multiple credentials 
on a socket. Please authenticate using MongoClient.connect with auth 
credentials.

所以我一直试图在Heroku上部署我的Node.js应用程序几天,但收效甚微。这确实引起了一些挫折,因为我需要在我的网站上运行这个应用程序。运行命令heroku local web在端口5000上呈现应用程序的工作版本。

2017-09-03T18:51:34.158304+00:00 app[web.1]: failed to connect to 
server [localhost:27017] on first connect [MongoError: connect 
ECONNREFUSED 127.0.0.1:27017]

我认为这意味着我正在使用的MongoDB数据库存在问题。在生产中部署应用程序时,我使用mLab作为数据库。我在我的代码中添加了mLab所需的连接,但它不起作用。如果有人可以帮助我,我真的很感激吗?

另外,我是否需要将安装了npm install的模块部署到heroku以使应用程序正常工作?我认为在运行npm install时安装的软件包可能存在问题。有人能指出我这个问题吗?

这是代码的链接,可能会下载文件并查看并在本地测试应用程序,如果可能的话,尝试将其部署到Heroku。

1 个答案:

答案 0 :(得分:0)

因为您需要更改网址there

ps:不要让您的数据库凭据在开源存储库中......