Heroku-bash:节点:找不到命令。处理错误代码127

时间:2019-05-13 20:32:04

标签: node.js heroku deployment

我正在为无法将节点应用程序部署到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登出任何有价值的东西,但这只给我带来了Process error code127。

有人可以帮助我解决这个问题吗?

我尝试了heroku node.js bash: node: command not found中建议的操作,但无济于事。这个问题是7年前问过的,但从未回答过,所以我很确定我的问题在这里有所不同。

Heroku团队有没有人可以帮助我解决这个问题?最近,我尝试强制在版本npm中使用6.5.0,但这没有任何效果。我已经阅读了整个https://devcenter.heroku.com/articles/troubleshooting-node-deploys,并应用了所有建议。如何强制Heroku给我更多有关到底是什么问题的信息?

编辑:

我也尝试了没有Procfile的情况,但该应用仍然无法正常工作。现在,我收到bash: npm: command not found,因此感到非常沮丧,因为我在Heroku上部署了另一个Node.js应用程序,并且该应用程序部署没有问题。

编辑:

我已经检查了多次,并且构建集为heroku/nodejs。我还可以通过其他方式将这个应用程序部署到heroku吗?

此外,这是我可以在Heroku控制台中看到的日志的屏幕

enter image description here

日志文件-文本版本:

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支持页面上举票后,我收到了有关我的应用程序像容器化应用程序的信息。在这种情况下,我对此无能为力,必须等到支持团队解决我的问题

2 个答案:

答案 0 :(得分:1)

我不确定您面临的具体问题是什么,但我可以为您提供一些提示。

我还希望您已经检查了通用解决方案,例如检查是否设置了官方构建包或设置了 package.json 等中指定的节点引擎。

如果所有这些都不起作用,您可以尝试使用heroku restart

答案 1 :(得分:0)

我对heroku并不熟悉,但是我可以说,每当您遇到“重击:未找到空白”错误时,这通常意味着您正在不了解该命令的地方使用该命令。

因此,在这种情况下,节点未安装在当前工作目录已知的位置。也许您是在告诉heroku一个不正确的位置来寻找节点或其他东西,或者只是节点未正确安装。检查节点的安装位置,是否需要告诉heroku节点的安装位置,然后确保搜索路径正确?