Patryk Jabłoński
Patryk Jabłoński

Reputation: 747

Heroku - bash: node: command not found. Process error code 127

I am struggling with the problem that I am not able to deploy my node application to the Heroku. Previously I have done it several times and everything was working like a charm. Now I encounter bash: node: command not found. I have no idea what to do to get rid of this problem.

My Procfile:

web: node ./src/index.js

My 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"
  }
}

and my 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}`)
})

I have tried to log out anything valuable by using heroku logs -t but this does not give me anything more than Process error code 127.

Can anyone help me with this problem?

I have tried things suggested in the heroku node.js bash: node: command not found but nothing helped. That question was asked 7 years ago and never answered, so I am pretty sure that my problem is different here.

Is there anyone from the Heroku team that could help me with the problem? Recently I have tried to force the use of the npm in version 6.5.0 and this has no effect. I have read the whole https://devcenter.heroku.com/articles/troubleshooting-node-deploys and applied all of the suggestions. How can I force Heroku to give me more info about what is exactly the problem?

EDIT:

I have also tried without the Procfile and app still does not work. Now I receive bash: npm: command not found so I am getting pretty frustrated, because of that I have another Nodejs app deployed on the Heroku and it is deploying without a problem.

EDIT:

I have checked for multiple times and the buildset is heroku/nodejs. Is there anything else that I can do to deploy this app to the heroku somehow?

Additionally here is a screen of the logs that I can see in the Heroku console

enter image description here

The log file - text version:

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 [email protected]
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 [email protected]
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 [email protected]
2019-05-21T08:22:20.927103+00:00 app[api]: Release v30 created by user [email protected]
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

After raising a ticket in the Heroku support page I received info that my application acts like a containerized app. In this case, I am not able to do anything about that and I have to wait till support team fix my issue

Upvotes: 1

Views: 2862

Answers (2)

clocksw
clocksw

Reputation: 78

I am not familiar with heroku, but I can say that whenever you have a "bash: BLANK not found" error it usually means you are using the command from somewhere that does not know about the command.

So, in this case, node is not installed in a location that the current working directory knows about. Maybe you are telling heroku an incorrect location to look for node or something, or node is just not properly installed. Check where node is installed and if you need to tell heroku where it is installed then make sure the search paths are correct?

Upvotes: 0

PrivateOmega
PrivateOmega

Reputation: 2880

I cannot be sure as to what the problem might be that you are facing specifically but I can maybe provide you with some pointers.

Also I am hoping you have already checked out the generic solutions like checking if the official build pack is set or setting node engine's specified in package.json etc.

If all these doesn't work, could you try a heroku restart.

Upvotes: 1

Related Questions