【发布时间】:2019-09-30 20:06:25
【问题描述】:
我正在努力解决无法将节点应用程序部署到 Heroku 的问题。以前我已经做过好几次了,一切都像魅力一样工作。现在我遇到bash: node: command not found。我不知道该怎么做才能摆脱这个问题。
我的Procfile:
web: node ./src/index.js
我的package.json:
{
"name": "scheduler_be",
"version": "1.0.0",
"description": "",
"main": "./src/index.js",
"scripts": {
"test": "jest --forceExit",
"start": "nodemon ./src/index.js --development"
},
"repository": {
"type": "git",
"url": "git+https://github.com/jablonskipj/scheduler-be.git"
},
"author": "Patryk Jablonski",
"license": "ISC",
"bugs": {
"url": "https://github.com/jablonskipj/scheduler-be/issues"
},
"homepage": "https://github.com/jablonskipj/scheduler-be#readme",
"dependencies": {
"body-parser": "^1.19.0",
"express": "^4.16.4",
"jest": "^24.1.0",
"knex": "^0.16.5",
"node": "^12.2.0",
"node-cron": "^2.0.3",
"nodemon": "^1.18.9",
"npm": "^6.9.0",
"pg": "^7.8.0",
"pg-hstore": "^2.3.2",
"smsapi": "^1.5.7"
},
"engines": {
"node": "12.2.0"
}
}
还有我的index.js:
const express = require('express')
const reminderRoutes = require('./routes/Routes')
const bodyParser = require('body-parser')
const PORT = process.env.PORT || 8006
console.log(PORT)
const app = express()
app.use(bodyParser.json())
app.use('/reminder', reminderRoutes)
app.listen(PORT, () => {
console.log(`app listening on port ${PORT}`)
})
我尝试使用heroku logs -t 注销任何有价值的东西,但这并没有给我更多的信息,只是处理错误代码 127。
谁能帮我解决这个问题?
我尝试了heroku node.js bash: node: command not found 中建议的方法,但没有任何帮助。这个问题是 7 年前提出的,但从未得到回答,所以我很确定我的问题在这里有所不同。
Heroku 团队中是否有人可以帮助我解决这个问题?最近我试图在6.5.0 版本中强制使用npm,但这没有效果。我已经阅读了整个https://devcenter.heroku.com/articles/troubleshooting-node-deploys 并应用了所有建议。我怎样才能强迫 Heroku 给我更多关于究竟是什么问题的信息?
编辑:
我也尝试过不使用Procfile,但应用程序仍然无法运行。现在我收到了bash: npm: command not found,所以我感到非常沮丧,因为我在 Heroku 上部署了另一个 Nodejs 应用程序,它的部署没有问题。
编辑:
我已经检查了多次,构建集是heroku/nodejs。我还能做些什么来以某种方式将此应用程序部署到 heroku?
另外这里是我可以在 Heroku 控制台中看到的日志屏幕
日志文件 - 文本版本:
2019-05-21T06:59:52.401049+00:00 heroku[web.1]: Starting process with command `node index.js`
2019-05-21T06:59:53.969667+00:00 heroku[web.1]: State changed from starting to crashed
2019-05-21T06:59:53.952550+00:00 heroku[web.1]: Process exited with status 127
2019-05-21T06:59:53.901105+00:00 app[web.1]: bash: node: command not found
2019-05-21T08:01:13.046896+00:00 app[api]: Starting process with command `node src/schedule.js` by user scheduler@addons.heroku.com
2019-05-21T08:01:18.939306+00:00 heroku[scheduler.8582]: Starting process with command `node src/schedule.js`
2019-05-21T08:01:19.672108+00:00 heroku[scheduler.8582]: State changed from starting to up
2019-05-21T08:01:20.475107+00:00 heroku[scheduler.8582]: State changed from up to complete
2019-05-21T08:01:20.454340+00:00 heroku[scheduler.8582]: Process exited with status 127
2019-05-21T08:01:20.379550+00:00 app[scheduler.8582]: bash: node: command not found
2019-05-21T08:21:17.000000+00:00 app[api]: Build started by user manilandiasalon@gmail.com
2019-05-21T08:22:22.166110+00:00 heroku[web.1]: State changed from crashed to starting
2019-05-21T08:22:27.607552+00:00 heroku[web.1]: Starting process with command `node index.js`
2019-05-21T08:22:29.106294+00:00 heroku[web.1]: State changed from starting to crashed
2019-05-21T08:22:29.182031+00:00 heroku[web.1]: State changed from crashed to starting
2019-05-21T08:22:29.086883+00:00 heroku[web.1]: Process exited with status 127
2019-05-21T08:22:28.981729+00:00 app[web.1]: bash: node: command not found
2019-05-21T08:22:20.927103+00:00 app[api]: Deploy d783e9a4 by user manilandiasalon@gmail.com
2019-05-21T08:22:20.927103+00:00 app[api]: Release v30 created by user manilandiasalon@gmail.com
2019-05-21T08:22:36.960377+00:00 heroku[web.1]: Starting process with command `node index.js`
2019-05-21T08:22:39.080765+00:00 heroku[web.1]: State changed from starting to crashed
2019-05-21T08:22:39.061234+00:00 heroku[web.1]: Process exited with status 127
2019-05-21T08:22:38.981195+00:00 app[web.1]: bash: node: command not found
2019-05-21T08:22:27.000000+00:00 app[api]: Build succeeded
在 Heroku 支持页面上提出请求后,我收到信息表明我的应用程序就像一个容器化应用程序。在这种情况下,我对此无能为力,我必须等到支持团队解决我的问题
【问题讨论】:
-
@Garret 最终结果似乎是相同的,但是您链接的主题已经快 7 年了,我很确定它对我的问题没有任何影响。此外,我已经尝试了它的所有建议,但没有任何效果。有什么改变可以帮助我解决这个问题吗?
-
@PatrykJabłoński 您能否将整个日志添加为文本文件而不是图像并从中删除任何秘密?
-
@PrivateOmega 完成 :)
标签: node.js heroku deployment