gpt4 book ai didi

node.js - Heroku Node.js 错误,代码=H10 desc ="App crashed"

转载 作者:搜寻专家 更新时间:2023-11-01 00:03:38 30 4
gpt4 key购买 nike

我浏览了很多类似的主题,但到目前为止无法解决我的问题。

我创建了一个 MERN 应用程序,将 Amazon 用于我的 Assets 并尝试将其部署在 Heroku 上。

我的应用程序在本地运行,但当我将它部署到 Heroku 上时,出现“应用程序错误”。当我查看 heroku 日志 --tail 时,这是我得到的最终错误:

2019-04-27T12:49:01.084214+00:00 heroku[router]: at=error code=H10 desc="App crashed" method=GET path="/" host=calm-earth-15269.herokuapp.com request_id=b2953cc1-6894-4697-8fc4-17d5012c536e fwd="93.11.10.123" dyno= connect= service= status=503 bytes= protocol=https
2019-04-27T12:49:01.622395+00:00 heroku[router]: at=error code=H10 desc="App crashed" method=GET path="/favicon.ico" host=calm-earth-15269.herokuapp.com request_id=2a9fbdbb-a35d-4ba1-a032-b263110e10db fwd="93.11.10.123" dyno= connect= service= status=503 bytes= protocol=https

这是完整的日志:

2019-04-27T12:48:09.000000+00:00 app[api]: Build succeeded
2019-04-27T12:48:24.009559+00:00 heroku[web.1]: Starting process with command `npm start`
2019-04-27T12:48:27.790744+00:00 app[web.1]:
2019-04-27T12:48:27.790767+00:00 app[web.1]: > joystock@1.0.0 start /app
2019-04-27T12:48:27.790768+00:00 app[web.1]: > node server.js
2019-04-27T12:48:27.790770+00:00 app[web.1]:
2019-04-27T12:48:29.369354+00:00 app[web.1]:
2019-04-27T12:48:29.369392+00:00 app[web.1]: /app/node_modules/mongoose/lib/connection.js:465
2019-04-27T12:48:29.369396+00:00 app[web.1]: throw new MongooseError('The `uri` parameter to `openUri()` must be a ' +
2019-04-27T12:48:29.369397+00:00 app[web.1]: ^
2019-04-27T12:48:29.369917+00:00 app[web.1]: MongooseError: The `uri` parameter to `openUri()` must be a string, got "undefined". Make sure the first parameter to `mongoose.connect()` or `mongoose.createConnection()` is a string.
2019-04-27T12:48:29.369920+00:00 app[web.1]: at new MongooseError (/app/node_modules/mongoose/lib/error/mongooseError.js:14:11)
2019-04-27T12:48:29.369923+00:00 app[web.1]: at NativeConnection.Connection.openUri (/app/node_modules/mongoose/lib/connection.js:465:11)
2019-04-27T12:48:29.369925+00:00 app[web.1]: at Mongoose.connect (/app/node_modules/mongoose/lib/index.js:289:15)
2019-04-27T12:48:29.369928+00:00 app[web.1]: at Object.<anonymous> (/app/server.js:25:4)
2019-04-27T12:48:29.369930+00:00 app[web.1]: at Module._compile (module.js:653:30)
2019-04-27T12:48:29.369932+00:00 app[web.1]: at Object.Module._extensions..js (module.js:664:10)
2019-04-27T12:48:29.369933+00:00 app[web.1]: at Module.load (module.js:566:32)
2019-04-27T12:48:29.369935+00:00 app[web.1]: at tryModuleLoad (module.js:506:12)
2019-04-27T12:48:29.369936+00:00 app[web.1]: at Function.Module._load (module.js:498:3)
2019-04-27T12:48:29.369938+00:00 app[web.1]: at Function.Module.runMain (module.js:694:10)
2019-04-27T12:48:29.369939+00:00 app[web.1]: at startup (bootstrap_node.js:204:16)
2019-04-27T12:48:29.369942+00:00 app[web.1]: at bootstrap_node.js:625:3
2019-04-27T12:48:29.430850+00:00 app[web.1]: npm ERR! code ELIFECYCLE
2019-04-27T12:48:29.434765+00:00 app[web.1]: npm ERR! errno 1
2019-04-27T12:48:29.436805+00:00 app[web.1]: npm ERR! joystock@1.0.0 start: `node server.js`
2019-04-27T12:48:29.437062+00:00 app[web.1]: npm ERR! Exit status 1
2019-04-27T12:48:29.437419+00:00 app[web.1]: npm ERR!
2019-04-27T12:48:29.437721+00:00 app[web.1]: npm ERR! Failed at the joystock@1.0.0 start script.
2019-04-27T12:48:29.438013+00:00 app[web.1]: npm ERR! This is probably not a problem with npm. There is likely additional logging output above.
2019-04-27T12:48:29.457869+00:00 app[web.1]:
2019-04-27T12:48:29.458356+00:00 app[web.1]: npm ERR! A complete log of this run can be found in:
2019-04-27T12:48:29.458709+00:00 app[web.1]: npm ERR! /app/.npm/_logs/2019-04-27T12_48_29_440Z-debug.log
2019-04-27T12:48:29.555420+00:00 heroku[web.1]: State changed from starting to crashed
2019-04-27T12:48:29.559599+00:00 heroku[web.1]: State changed from crashed to starting
2019-04-27T12:48:29.536335+00:00 heroku[web.1]: Process exited with status 1
2019-04-27T12:48:38.161883+00:00 heroku[web.1]: Starting process with command `npm start`
2019-04-27T12:48:40.468366+00:00 app[web.1]:
2019-04-27T12:48:40.468385+00:00 app[web.1]: > joystock@1.0.0 start /app
2019-04-27T12:48:40.468387+00:00 app[web.1]: > node server.js
2019-04-27T12:48:40.468388+00:00 app[web.1]:
2019-04-27T12:48:41.210741+00:00 app[web.1]:
2019-04-27T12:48:41.210778+00:00 app[web.1]: /app/node_modules/mongoose/lib/connection.js:465
2019-04-27T12:48:41.210781+00:00 app[web.1]: throw new MongooseError('The `uri` parameter to `openUri()` must be a ' +
2019-04-27T12:48:41.210783+00:00 app[web.1]: ^
2019-04-27T12:48:41.211208+00:00 app[web.1]: MongooseError: The `uri` parameter to `openUri()` must be a string, got "undefined". Make sure the first parameter to `mongoose.connect()` or `mongoose.createConnection()` is a string.
2019-04-27T12:48:41.211212+00:00 app[web.1]: at new MongooseError (/app/node_modules/mongoose/lib/error/mongooseError.js:14:11)
2019-04-27T12:48:41.211214+00:00 app[web.1]: at NativeConnection.Connection.openUri (/app/node_modules/mongoose/lib/connection.js:465:11)
2019-04-27T12:48:41.211216+00:00 app[web.1]: at Mongoose.connect (/app/node_modules/mongoose/lib/index.js:289:15)
2019-04-27T12:48:41.211218+00:00 app[web.1]: at Object.<anonymous> (/app/server.js:25:4)
2019-04-27T12:48:41.211219+00:00 app[web.1]: at Module._compile (module.js:653:30)
2019-04-27T12:48:41.211221+00:00 app[web.1]: at Object.Module._extensions..js (module.js:664:10)
2019-04-27T12:48:41.211222+00:00 app[web.1]: at Module.load (module.js:566:32)
2019-04-27T12:48:41.211224+00:00 app[web.1]: at tryModuleLoad (module.js:506:12)
2019-04-27T12:48:41.211225+00:00 app[web.1]: at Function.Module._load (module.js:498:3)
2019-04-27T12:48:41.211227+00:00 app[web.1]: at Function.Module.runMain (module.js:694:10)
2019-04-27T12:48:41.211228+00:00 app[web.1]: at startup (bootstrap_node.js:204:16)
2019-04-27T12:48:41.211231+00:00 app[web.1]: at bootstrap_node.js:625:3
2019-04-27T12:48:41.220629+00:00 app[web.1]: npm ERR! code ELIFECYCLE
2019-04-27T12:48:41.221020+00:00 app[web.1]: npm ERR! errno 1
2019-04-27T12:48:41.222262+00:00 app[web.1]: npm ERR! joystock@1.0.0 start: `node server.js`
2019-04-27T12:48:41.222424+00:00 app[web.1]: npm ERR! Exit status 1
2019-04-27T12:48:41.222687+00:00 app[web.1]: npm ERR!
2019-04-27T12:48:41.222855+00:00 app[web.1]: npm ERR! Failed at the joystock@1.0.0 start script.
2019-04-27T12:48:41.223019+00:00 app[web.1]: npm ERR! This is probably not a problem with npm. There is likely additional logging output above.
2019-04-27T12:48:41.228089+00:00 app[web.1]:
2019-04-27T12:48:41.228288+00:00 app[web.1]: npm ERR! A complete log of this run can be found in:
2019-04-27T12:48:41.228431+00:00 app[web.1]: npm ERR! /app/.npm/_logs/2019-04-27T12_48_41_224Z-debug.log
2019-04-27T12:48:41.314693+00:00 heroku[web.1]: State changed from starting to crashed
2019-04-27T12:48:41.291941+00:00 heroku[web.1]: Process exited with status 1
2019-04-27T12:49:01.084214+00:00 heroku[router]: at=error code=H10 desc="App crashed" method=GET path="/" host=calm-earth-15269.herokuapp.com request_id=b2953cc1-6894-4697-8fc4-17d5012c536e fwd="93.11.10.123" dyno= connect= service= status=503 bytes= protocol=https
2019-04-27T12:49:01.622395+00:00 heroku[router]: at=error code=H10 desc="App crashed" method=GET path="/favicon.ico" host=calm-earth-15269.herokuapp.com request_id=2a9fbdbb-a35d-4ba1-a032-b263110e10db fwd="93.11.10.123" dyno= connect= service= status=503 bytes= protocol=https


我已经尝试/检查过:

  • 港口
const port = process.env.PORT || 5000;

app.listen(port, () => console.log(`Joystock Server running on port ${port}`));
  • 试过:heroku 重启

  • 在我的 package.json 文件中添加引擎版本

"engines": {
"node": "8.12.0",
"npm": "6.4.1"
},
  • 我的配置变量 (mongoURI) 已在我的 heroku 设置中为此应用正确定义。

  • 我还尝试从头开始完全重新创建该应用,并且一切都是最新的。

  • 起初,我没有为 '/' 添加定义的路由,所以我尝试在 routes/tracks.js

  • 中添加一个
router.get('/', (req, res) => {
res.redirect('/all/page-1');
});

不管有没有这条路线,我得到的结果都是一样的。

...我总是以同样的错误告终。


这是我当前用于此应用程序的 git 存储库: https://github.com/Karaza/joystock


我不知道下一步该怎么做来修复我的应用。

预先感谢您的帮助(:

最佳答案

在文件中:joystock/config/keys.js...确保 NODE_ENV 是生产环境?没有 keys_dev 文件。

if (process.env.NODE_ENV === 'production') {
module.exports = require('./keys_prod');
} else {
module.exports = require('./keys_dev');
}

我不熟悉 heroku,但看起来你禁用了生产模式。

"heroku-postbuild": "NPM_CONFIG_PRODUCTION=false npm install --prefix client && npm run build --prefix client"

所以我认为需要检查:

process.env.MONGO_URI
process.env.NODE_ENV

关于node.js - Heroku Node.js 错误,代码=H10 desc ="App crashed",我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/55881052/

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