node.js - 在 Heroku 上成功部署我的 node.js 缺少什么
问题描述
我花了很多时间来做与 heroku 手册中的 node.js 部署完全相同的事情。我使用 nedb 作为数据存储和 node.js 14.x。其中之一是问题吗?没有进一步的计划它可能是什么。
heroku日志
2020-11-09T07:11:42.803302+00:00 app[web.1]: Warning: connect.session() MemoryStore is not
2020-11-09T07:11:42.803322+00:00 app[web.1]: designed for a production environment, as it will leak
2020-11-09T07:11:42.803323+00:00 app[web.1]: memory, and will not scale past a single process.
2020-11-09T07:11:42.812099+00:00 app[web.1]: Server running at http://localhost:49728/
2020-11-09T07:12:40.832978+00:00 heroku[web.1]: Error R10 (Boot timeout) -> Web process failed to bind to $PORT within 60 seconds of launch
2020-11-09T07:12:40.849869+00:00 heroku[web.1]: Stopping process with SIGKILL
2020-11-09T07:12:40.929805+00:00 heroku[web.1]: Process exited with status 137
2020-11-09T07:12:40.964808+00:00 heroku[web.1]: State changed from starting to crashed
档案
"scripts": {
"start": "node app.js"
}
包.json
{
"name": "test",
"version": "1.0.0",
"description": "Demo",
"main": "app.js",
"scripts": {
"start": "node app.js",
},
"type": "module",
"engines": {
"node": "14.x"
},
"dependencies": {
"body-parser": "^1.19.0",
"express": "^4.17.1",
"express-session": "^1.17.1",
"hbs": "^2.9.0",
"method-override": "^3.0.0",
"nedb": "^1.8.0",
"nedb-promise": "^2.0.1",
"nedb-promises-ts": "0.0.1-4",
"prettier": "^2.1.2",
"typescript": "^4.0.3"
},
"devDependencies": {
"@types/express": "^4.17.8",
"@types/nedb": "^1.8.11",
"@types/node": "^14.14.2",
"@typescript-eslint/eslint-plugin": "^4.4.1",
"@typescript-eslint/parser": "^4.4.1",
"eslint": "^7.11.0",
"eslint-config-prettier": "^6.13.0"
}
}
应用程序.js
import express from "express";
import { indexRoutes } from "./routes/indexRoutes.js";
...
const app = express();
...
app.use("/", indexRoutes);
...
const hostname = "localhost";
const port = process.env.PORT || 3000;
app.listen(port, hostname, () => {
console.log(`Server running at http://${hostname}:${port}/`);
});
解决方案
推荐阅读
- c# - Newtonsoft NullValueHandling.Ignore 在序列化时似乎没有删除空值
- dotnetrdf - dotnetRDF 上的 VDS.RDF.Query.RdfQueryTimeoutException
- javascript - React JS 自定义表格 - 处理表格中的选择下拉列表
- python - python打开一个.xls文件一个smb服务器
- python - 通过在 python 中提供条件来创建多个数据框
- flutter - 需要一些帮助来解决这个问题“方法 'addListener' 是在 null 上调用的。”
- python - pip install 只在包中安装顶级 Python 文件
- sql - SQL/Doctrine - 使用 AND 过滤结果(多对多)
- angular - ng2-search-filter 在离子 4 中给出错误
- datetime - 类 ClockTriggerBuilder:特定日期和时间(仅一次)Google Sheet 脚本中的触发器每分钟不断重复执行