30

I am getting some kind of error when deploying my app to heroku using git hub. The problem is, I don't understand the heroku logs and the entailing errors. Here is the heroku log:

Marcuss-MacBook-Pro:Weather-App marcushurney$ heroku logs
2016-01-05T14:37:27.798077+00:00 app[web.1]: npm ERR! Please include the following file with any support request:
2016-01-05T14:37:27.798377+00:00 app[web.1]: npm ERR!     /app/npm-debug.log
2016-01-05T14:37:27.786949+00:00 app[web.1]: npm ERR! node v5.1.1
2016-01-05T14:37:27.786556+00:00 app[web.1]: npm ERR! argv "/app/.heroku/node/bin/node" "/app/.heroku/node/bin/npm" "start"
2016-01-05T14:37:27.787856+00:00 app[web.1]: npm ERR! npm  v3.3.12
2016-01-05T14:37:28.776245+00:00 heroku[web.1]: Process exited with status 1
2016-01-05T14:37:28.789412+00:00 heroku[web.1]: State changed from starting to crashed
2016-01-05T17:27:16.684869+00:00 heroku[web.1]: State changed from crashed to starting
2016-01-05T17:27:17.853743+00:00 heroku[web.1]: Starting process with command `npm start`
2016-01-05T17:27:20.423495+00:00 app[web.1]: npm ERR! node v5.1.1
2016-01-05T17:27:20.423130+00:00 app[web.1]: npm ERR! argv "/app/.heroku/node/bin/node" "/app/.heroku/node/bin/npm" "start"
2016-01-05T17:27:20.424111+00:00 app[web.1]: npm ERR! npm  v3.3.12
2016-01-05T17:27:20.425937+00:00 app[web.1]: npm ERR! missing script: start
2016-01-05T17:27:20.422441+00:00 app[web.1]: npm ERR! Linux 3.13.0-71-generic
2016-01-05T17:27:20.426242+00:00 app[web.1]: npm ERR! 
2016-01-05T17:27:20.426432+00:00 app[web.1]: npm ERR! If you need help, you may report this error at:
2016-01-05T17:27:20.426634+00:00 app[web.1]: npm ERR!     <https://github.com/npm/npm/issues>
Ale Gu
  • 146
  • 9
Mjuice
  • 1,288
  • 2
  • 13
  • 32

7 Answers7

80

You have to inform heroku where to start : missing script: start. In your package.json, you should have something like this:

"scripts": {
  "start": "node index.js"
}

Where index.js is your entry point.

As an alternative, you can specify in Procfile:

web: node index.js
Preview
  • 35,317
  • 10
  • 92
  • 112
L. Meyer
  • 2,863
  • 1
  • 23
  • 26
  • That fixed things up! – Mjuice Jan 08 '16 at 06:34
  • 2
    @LMeyer it still doesn't fix it for me. Any ideas? I already included the start in the package.json – sguan Jul 02 '16 at 04:59
  • @TheProgrammerG Pretty sure if you added the start, you don't have `missing script: start` in the logs. What do you have ? – L. Meyer Jul 03 '16 at 07:58
  • You saved me so much time! Thanks! – chris123 Aug 03 '16 at 16:31
  • 2
    what if it's a typescript + node, express app? – uber Jun 10 '21 at 17:35
  • What if my site has an index.html, but no index.js? Would I just write `"main": "index.html", "scripts": { "start": "node index.js" }` and add a starter index.js file just for Heroku? But then what about this line? `res.render('pages/index')` – Edison Feb 17 '22 at 10:07
  • @edison why would you use a `html` file in a `node` app and not a starting `js file`? Do you have a static webserver serving only html? Then use npm package `http-server` and look [here](https://stackoverflow.com/a/47620425/1705829) – Timo Feb 19 '22 at 19:43
  • I would only link to the second link where the `start` key of `scripts` in the package.json is explained. The first link explains `build` which is not what the OP wants. – Timo Feb 19 '22 at 19:48
  • @uber, look [here](https://stackoverflow.com/a/45742138/1705829) for your answer, just install `ts-node` and `typescript` locally and adapt your `scripts,start` entry in `package.json. – Timo Feb 19 '22 at 20:03
6

My silly mistake was that I was pushing the master branch to Heroku while my changes were in another branch!

Make sure that you merge your latest branch with your master branch first

> git checkout master

> git merge your-latest-branch

> git push heroku master
Dawit Abraham
  • 1,616
  • 15
  • 19
4

In my case, changing this:

"scripts": {
     "test": "echo \"Error: no test specified\" && exit 1"
    },

to this:

"scripts": {
   "start": "node app.js"
    },

was the solution

Zameer Ansari
  • 28,977
  • 24
  • 140
  • 219
3

For some reason pushing the start script to top fixed the problem

So instead of

"scripts": {
    "test": "jest",
    "start": "node app.js"
}

I did

"scripts": {
    "start": "node app.js",
    "test": "jest"

}
Zeyad Shaban
  • 896
  • 1
  • 8
  • 23
  • Thanks you! Wasn't working until I tried that. Also I had to add the Procfile file with "web: node app.js" – Miguel Mar 20 '22 at 15:17
2

I also faced similar kind of errors for my node js app while publishing it to heroku.com

First create a procfile, procfile is a simple text file but without any extension.

Place only one line in procfile as of now.

web: npm start

Now create the package.json file using command

npm init

once your package.json file got created please place the start property inside scripts.

"scripts": {
    "start": "node app.js",
    "test": "echo \"Error: no test specified\" && exit 1"
  },

now commit all (procfile/package.json) pending files. and deploy app again from heroku.

Rahul Sonone
  • 2,685
  • 1
  • 27
  • 38
0

I encountered the same issue on this trying to deploy my server with heroku after several troubleshooting. The changes i made to my package.json which includes creating a start property into your script;

"scripts": {
  "test": "echo \"Error: no test specified\" && exit 1",
  "start": "node app.js"
},

After making the changes, ensure your Procfile without extension has this one line;

  web: node app.js (Depends on your server file).

Then you can proceed to commit your files.

Hopefully this helps

Alexey Osetsky
  • 168
  • 2
  • 10
0

I was using nodemon.js so I included it in the package.json as following: "scripts"

 "scripts": {
        "test": "echo \"Error: no test specified\" && exit 1",
        "dev": "nodemon index.js",
     },

But I got this Heroku error:

2022-01-06T11:51:55.044364+00:00 heroku[web.1]: Starting process with command npm start 2022-01-06T11:51:57.390306+00:00 app[web.1]: npm ERR! missing script: start 2022-01-06T11:51:57.398106+00:00 app[web.1]: 2022-01-06T11:51:57.398334+00:00 app[web.1]: npm ERR! A complete log of this run can be found in: 2022-01-06T11:51:57.398402+00:00 app[web.1]: npm ERR!
/app/.npm/_logs/2022-01-06T11_51_57_391Z-debug.log 2022-01-06T11:51:57.598054+00:00 heroku[web.1]: Process exited with status 1 2022-01-06T11:51:57.882212+00:00 heroku[web.1]: State changed from starting to crashed 2022-01-06T11:51:57.953568+00:00 heroku[web.1]: State changed from crashed to starting 2022-01-06T11:52:00.240909+00:00 heroku[web.1]: Starting process with command npm start 2022-01-06T11:52:02.010859+00:00 app[web.1]: npm ERR! missing script: start 2022-01-06T11:52:02.014370+00:00 app[web.1]: 2022-01-06T11:52:02.014567+00:00 app[web.1]: npm ERR! A complete log of this run can be found in: .................................etc

I found out that Heroku uses "npm start" to run our app meanwhile I didn't include it in the package.json; so included it as the following:

"scripts": {
    "test": "echo \"Error: no test specified\" && exit 1",
    "dev": "nodemon index.js",
    "start": "node index.js"
  },

Then restarted the git processes:

-heroku restart
-heroku git:remote -a app_name
-git add .
-git commit -am "Your commit"
-git push heroku master

And everything worked well.

demarsylvain
  • 2,103
  • 2
  • 14
  • 33