Search code examples
node.jsfacebookherokuchatbot

missing script: start & App crashed when deploying app to Heroku


I'm new to coding but currently learning as i want to create a chatbot to my facebook page. Belows are the script i have inside each .js and errors that i came across after that. After i input heroku open, the web shows "Application error An error occurred in the application and your page could not be served. If you are the application owner, check your logs for details."

Hope someone can help me out, a lot of thanks!

index.js

var express = require('express')
var bodyParser = require('body-parser')
var request = require('request')
var app = express()

app.set('port', (process.env.PORT || 5000))

// Process application/x-www-form-urlencoded
app.use(bodyParser.urlencoded({extended: false}))

// Process application/json
app.use(bodyParser.json())

// Index route
app.get('/', function (req, res) {
    res.send('Hello world, I am a chat bot')
})

// for Facebook verification
app.get('/webhook/', function (req, res) {
    if (req.query['hub.verify_token'] === 'my_voice_is_my_password_verify_me') {
        res.send(req.query['hub.challenge'])
    }
    res.send('Error, wrong token')
})

// Spin up the server
app.listen(app.get('port'), function() {
    console.log('running on port', app.get('port'))
})

package.json

{
    "name": "node",
    "version": "1.0.0",
    "description": "facebook chatbot",
    "main": "index.js",
    "scripts": {
        "start": "node index.js"
    },
    "author": "krix",
    "license": "ISC",
    "dependencies": {
        "body-parser": "^1.18.1",
        "express": "^4.15.4",
        "request": "^2.81.0"
    }
}

Procfile.json

web: node index.js

heroku logs:

2017-09-14T13:32:53.277012+00:00 app[api]: Release v2 created by user [email protected]
2017-09-14T13:32:53.277012+00:00 app[api]: Enable Logplex by user [email protected]
2017-09-14T13:32:53.049614+00:00 app[api]: Initial release by user [email protected]
2017-09-14T13:32:53.049614+00:00 app[api]: Release v1 created by user [email protected]
2017-09-14T13:33:16.000000+00:00 app[api]: Build started by user [email protected]
2017-09-14T13:33:44.501803+00:00 app[api]: Release v3 created by user [email protected]
2017-09-14T13:33:44.550885+00:00 app[api]: Scaled to web@1:Free by user [email protected]
2017-09-14T13:33:44.501803+00:00 app[api]: Deploy 30d98ae9 by user [email protected]
2017-09-14T13:33:16.000000+00:00 app[api]: Build succeeded
2017-09-14T13:33:47.445193+00:00 heroku[web.1]: Starting process with command `npm start`
2017-09-14T13:33:51.208413+00:00 app[web.1]: 
2017-09-14T13:33:51.208690+00:00 app[web.1]: npm ERR! A complete log of this run can be found in:
2017-09-14T13:33:51.208802+00:00 app[web.1]: npm ERR!     /app/.npm/_logs/2017-09-14T13_33_51_189Z-debug.log
2017-09-14T13:33:51.186998+00:00 app[web.1]: npm ERR! missing script: start
2017-09-14T13:33:51.326957+00:00 heroku[web.1]: State changed from starting to crashed
2017-09-14T13:33:51.329410+00:00 heroku[web.1]: State changed from crashed to starting
2017-09-14T13:33:51.312231+00:00 heroku[web.1]: Process exited with status 1
2017-09-14T13:33:53.384440+00:00 heroku[web.1]: Starting process with command `npm start`
2017-09-14T13:33:56.553788+00:00 app[web.1]: npm ERR! missing script: start
2017-09-14T13:33:56.567775+00:00 app[web.1]: 
2017-09-14T13:33:56.567944+00:00 app[web.1]: npm ERR! A complete log of this run can be found in:
2017-09-14T13:33:56.567995+00:00 app[web.1]: npm ERR!     /app/.npm/_logs/2017-09-14T13_33_56_555Z-debug.log
2017-09-14T13:33:56.688362+00:00 heroku[web.1]: Process exited with status 1
2017-09-14T13:33:56.703579+00:00 heroku[web.1]: State changed from starting to crashed
2017-09-14T13:34:34.169385+00:00 heroku[router]: at=error code=H10 desc="App crashed" method=GET path="/" host=boiling-fortress-15768.herokuapp.com request_id=d93942a9-fddf-426c-8604-39aaf8abe6a7 fwd="58.153.46.198" dyno= connect= service= status=503 bytes= protocol=https
2017-09-14T13:34:34.510184+00:00 heroku[router]: at=error code=H10 desc="App crashed" method=GET path="/favicon.ico" host=boiling-fortress-15768.herokuapp.com request_id=8b2d01d7-56f8-453b-a355-d58c9fd6ca85 fwd="58.153.46.198" dyno= connect= service= status=503 bytes= protocol=https
2017-09-14T13:37:20.203744+00:00 heroku[router]: at=error code=H10 desc="App crashed" method=GET path="/" host=boiling-fortress-15768.herokuapp.com request_id=884f9ef7-b7f9-4f49-bd57-6b509ec90f6f fwd="58.153.46.198" dyno= connect= service= status=503 bytes= protocol=https
2017-09-14T13:37:20.530728+00:00 heroku[router]: at=error code=H10 desc="App crashed" method=GET path="/favicon.ico" host=boiling-fortress-15768.herokuapp.com request_id=3ae40dba-5f53-4436-a406-1c45b6bab5af fwd="58.153.46.198" dyno= connect= service= status=503 bytes= protocol=https

I have tried and read through quite a lot of questions others have been asking on github, but i still cannot fix the problem. I learnt the method in setting up the nodejs and heroku server from the following website: https://chatbotsmagazine.com/have-15-minutes-create-your-own-facebook-messenger-bot-481a7db54892

I sincerely hope someone can help me out with the problems, thank you so much!!


Solution

  • The Procfile file name should be just Procfile, and I see that yours seems to be named Procfile.json, could be it.

    But as you package.json has the start script, just make sure you have git added all your files and committed them before pushing to Heroku