react-native - 为什么heroku因code=H10 status 503而崩溃
问题描述
我浪费了 10 个小时尝试将我的 expo react-native 应用程序与 mongodb 和 node js 部署到 heroku。
我仍然得到
heroku crashed with code=H10 status 503
我尝试了所有教程,
我的环境文件:
MONGO_URI=mongodb+srv://admin:admin@lior.rva16.mongodb.net/<dbname>?retryWrites=true&w=majority
JWT_SECRET=LKDSLCXIOZJSIAJ768
我的服务器包 json:
"scripts": {
"start": "node index.js",
"heroku-postbuild": "yarn run build:prod"
},
"engines": {
"node": "12.18.3"
},
我的档案:
web:node index.js
我的索引服务器:
const port = process.env.PORT || 3000;
const mongoURL = process.env.MONGO_URI;
//db
mongoose
.connect(mongoURL, {
useNewUrlParser: true,
useUnifiedTopology: true,
})
.then(() => console.log("DB Connected"));
mongoose.connection.on("error", err => {
console.log(`DB Connection error: ${err.message}`);
});
..........................
app.listen(port, () => {
console.log(`listening on port ${port}`);
});
我的完整项目在https://github.com/roeigr7/LIOR
请帮忙..为什么会崩溃?我究竟做错了什么?
我的错误来自 heroku:
2020-12-20T20:22:10.757245+00:00 app[web.1]: > @ start /app
2020-12-20T20:22:10.757245+00:00 app[web.1]: > expo start
2020-12-20T20:22:10.757245+00:00 app[web.1]:
2020-12-20T20:22:10.838503+00:00 app[web.1]: This command requires Expo CLI.
2020-12-20T20:22:10.904600+00:00 app[web.1]: Do you want to install it globally [Y/n]?
2020-12-20T20:23:10.866595+00:00 heroku[router]: at=error code=H10 desc="App
crashed" method=GET path="/nextMeet/by/5fac1f65a9e40443ccdf274b"
host=liormassage.herokuapp.com request_id=826c87fb-bb0e-4b72-87e5-
6225dfd790ca fwd="37.142.10.178" dyno= connect= service= status=503 bytes= protocol=https
解决方案
首先尝试这个https://dev.to/cpclark360/how-to-host-a-restful-node-js-server-with-mongodb-atlas-database-on-heroku-1opl以确保 mongoDB 已连接到 Heroku,然后看看你得到的错误 2020-12-20T20:22:10.838503+00:00 app[web.1]: This command requires Expo CLI
推荐阅读
- postgresql - 如何使用 postgres 11 从函数中的迭代中返回表
- bluetooth - 树莓派零,蓝牙通过 ttyS0 或 Serial0
- python-3.x - 如何在同一个列表中获取字符串的子集
- macos - cocos studio 打不开我在 Mac 上运行
- amazon-s3 - 将 s3 安装到 wowza ec2:无法“制作”s3fs-fuse
- r - R:如何将文件读入不同拆分的数据表中?
- regex - 正则表达式 - 选择所有没有特定属性且没有新行的
- elasticsearch - 如何在 heartbeat.yml 中添加更多监视器?
- java - 持久化 Spring OAuth2RestTemplate 的刷新令牌
- python - 如何将两个列表按顺序合并到一个新列表中?