当我部署我的构建时,构建总是成功并且也可以运行。但是,运行后几秒钟,它崩溃了,没有关于原因的日志。我已经使用heroku local web
命令在本地进行了测试,并且可以完美运行。我还使用了heroku bash来检查node_modules
,以确保正确安装了我的所有依赖项。我也尝试通过heroku bash运行,但是发生了相同的错误。在本地和远程上,节点和npm版本与版本node: >=10.16.0
和npm: >= 6.9.0
相同。我也尝试将文件(package-lock.json
和node_modules
除外)复制到新目录中,并使用npm install
和npm run start
,并且仍然可以在本地正常工作。有任何想法吗?
更新
我回滚到先前使用heroku的rollback命令进行的提交,并且网站已启动并正在运行。我创建了一个暂存分支并推送了更改,所以现在我要解决这个问题。问题是我只是希望日志中有某种错误消息,该错误消息可以指明其崩溃的原因,因为这使我难过了几天。
另一个更新
我安装了ubuntu来测试我的项目在linux操作系统上的运行,以查看是否可以重现此问题,但仍然可以正常运行。
**最终更新**通过完全从头开始并一次添加一件事,我设法使事情开始了。我知道这没有帮助,但是我想让这个问题公开,因为我仍然不知道是什么导致了这个问题。package.json
{
"name": "hayewoodbotapi-v2",
"version": "0.0.0",
"scripts": {
"start": "npm run prod",
"build": "npm-run-all clean transpile",
"server": "node ./dist-server/bin/www",
"prod": "npm-run-all build server",
"transpile": "webpack && babel server --source-maps --out-dir dist-server",
"clean": "rimraf dist-server"
},
"dependencies": {
"@babel/node": "^7.2.2",
"babel-loader": "^8.1.0",
"cookie-parser": "~1.4.4",
"crypto-js": "^4.0.0",
"debug": "~2.6.9",
"ejs": "^3.0.1",
"express": "^4.17.1",
"express-generator": "^4.16.1",
"express-session": "^1.17.0",
"http-errors": "~1.6.3",
"jade": "~1.11.0",
"lance-gg": "^4.0.8",
"morgan": "~1.9.1",
"nodemon": "^2.0.3",
"npm-run-all": "^4.1.5",
"passport": "^0.4.1",
"passport-oauth": "^1.0.0",
"passport-twitch": "^1.0.3",
"pg": "^7.18.2",
"query-string": "^6.12.0",
"regenerator-runtime": "^0.13.5",
"request": "^2.88.2",
"rimraf": "^3.0.2",
"sequelize": "^5.21.5",
"sequelize-cli": "^5.5.1",
"socket.io": "^2.3.0",
"webpack": "^3.8.1"
},
"engines": {
"node": ">=10.16.0",
"npm": ">=6.9.0"
},
"devDependencies": {
"@babel/cli": "^7.2.3",
"@babel/core": "^7.3.4",
"@babel/preset-env": "^7.3.4",
"eslint": "^3.16.1",
"express-swagger-generator": "^1.1.17"
}
}
这里是通过heroku记录的日志。可以看到它正在执行,因为我添加了console.log语句来输出端口。
2020-04-30T18:50:49.307843+00:00 app[web.1]: Successfully compiled 23 files with Babel.
2020-04-30T18:50:50.111523+00:00 app[web.1]:
2020-04-30T18:50:50.111537+00:00 app[web.1]: > [email protected] server /app 2020-04-30T18:50:50.111537+00:00 app[web.1]: > node ./dist-server/bin/www
2020-04-30T18:50:50.111538+00:00 app[web.1]:
2020-04-30T18:50:52.021984+00:00 app[web.1]: Warning: connect.session() MemoryStore is not
2020-04-30T18:50:52.021997+00:00 app[web.1]: designed for a production environment, as it will leak
2020-04-30T18:50:52.021998+00:00 app[web.1]: memory, and will not scale past a single process. 2020-04-30T18:50:52.028026+00:00 app[web.1]: PORT: 49175 2020-04-30T18:50:52.063057+00:00 app[web.1]: (node:138) [SEQUELIZE0004]
DeprecationWarning: A boolean value was passed to options.operatorsAliases.
This is a no-op with v5 and should be removed.
2020-04-30T18:50:52.063059+00:00 app[web.1]: (Use node --trace-deprecation ... to show where the
warning was created) 2020-04-30T18:50:52.243126+00:00 heroku[web.1]: State changed from starting to crashed
事实证明,我只需要升级节点版本和降级Webpack版本。