Mjuice
Mjuice

Reputation: 1288

Why do I obtain this error when deploying app to Heroku?

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>

Upvotes: 30

Views: 50478

Answers (7)

L. Meyer
L. Meyer

Reputation: 3253

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

How to use both

If you still want to use the start script from within the Procfile:

web: npm start

In this case, you can still feature your start script from the package.json file as it is the usual way to proceed and it will be taken into account by Heroku.

Upvotes: 81

lordvoldemort
lordvoldemort

Reputation: 85

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.

Upvotes: 0

Uthman Olajide
Uthman Olajide

Reputation: 1

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

Upvotes: 0

Zeyad Shaban
Zeyad Shaban

Reputation: 1016

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"

}

Upvotes: 3

Dawit Abraham
Dawit Abraham

Reputation: 1762

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

Upvotes: 6

Rahul Sonone
Rahul Sonone

Reputation: 2745

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.

Upvotes: 2

Mr.X
Mr.X

Reputation: 31345

In my case, changing this:

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

to this:

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

was the solution

Upvotes: 4

Related Questions