2017-03-20 57 views
-1

我是新手。我从https://www.sitepoint.com/building-facebook-chat-bot-node-heroku/以下教程来制作示例facebook messenger bot。Heroku继续使用命令`npm start'启动进程后崩溃

正当我在Heroku上部署它我第一次错误

这里是我的package.json

{ 
    "name": "spbot", 
    "version": "1.0.0", 
    "description": "Testbot", 
    "main": "app.js", 
    "scripts": { 
    "test": "echo \"Error: no test specified\" && exit 1", 
    "start": "node app.js" 
    }, 
    "author": "Munkh", 
    "license": "ISC", 
    "dependencies": { 
    "body-parser": "^1.17.1", 
    "express": "^4.15.2", 
    "mongoose": "^4.9.1", 
    "request": "^2.81.0" 
    } 
} 

这里是app.js

var express = require("express"); 
var request = require("request"); 
var bodyParser = require("body-parser"); 

var app = express(); 
app.use(bodyParser.urlencoded({extended: false})); 
app.use(bodyParser.json()); 
app.listen((process.env.PORT || 5000)); 

// Server index page 
app.get("/", function (req, res) { 
    res.send("Deployed!"); 
}); 

// Facebook Webhook 
// Used for verification 
app.get("/webhook", function (req, res) { 
    if (req.query["hub.verify_token"] === "this_is_my_token") { 
    console.log("Verified webhook"); 
    res.status(200).send(req.query["hub.challenge"]); 
    } else { 
    console.error("Verification failed. The tokens do not match."); 
    res.sendStatus(403); 
    } 
}); 

我有错误这样的

2017-03-20T02:11:15.997279+00:00 heroku[web.1]: State changed from crashed to starting 
2017-03-20T02:11:17.849748+00:00 heroku[web.1]: Starting process with command `npm start` 
2017-03-20T02:11:20.455381+00:00 app[web.1]: 
2017-03-20T02:11:20.455396+00:00 app[web.1]: > [email protected] start /app 
2017-03-20T02:11:20.455397+00:00 app[web.1]: > node app.js 
2017-03-20T02:11:20.455397+00:00 app[web.1]: 
2017-03-20T02:11:20.978077+00:00 heroku[web.1]: Process exited with status 0 
2017-03-20T02:11:20.994169+00:00 heroku[web.1]: State changed from starting to crashed 
2017-03-20T02:11:20.994986+00:00 heroku[web.1]: State changed from crashed to starting 
2017-03-20T02:11:23.337790+00:00 heroku[web.1]: Starting process with command `npm start` 
2017-03-20T02:11:27.660508+00:00 app[web.1]: 
2017-03-20T02:11:27.660527+00:00 app[web.1]: > node app.js 
2017-03-20T02:11:27.660526+00:00 app[web.1]: > [email protected] start /app 
2017-03-20T02:11:27.660528+00:00 app[web.1]: 
2017-03-20T02:11:27.896343+00:00 heroku[web.1]: State changed from starting to crashed 
2017-03-20T02:11:27.881546+00:00 heroku[web.1]: Process exited with status 0 

因为错误没有指定出错的地方,只是不断崩溃,所以我找不到解决方案。如果是简单的问题,我很抱歉。

回答

0

您必须指定您在package.json中使用的node.js和npm版本,如下所述。

指定您在开发中使用的版本。

{ 
    "name": "spbot", 
    "version": "1.0.0", 
    "description": "Testbot", 
    "main": "app.js", 
    "scripts": { 
    "test": "echo \"Error: no test specified\" && exit 1", 
    "start": "node app.js" 
    }, 
    "author": "Munkh", 
    "license": "ISC", 
    "dependencies": { 
    "body-parser": "^1.17.1", 
    "express": "^4.15.2", 
    "mongoose": "^4.9.1", 
    "request": "^2.81.0" 
    }, 
    "engines": { 
    "node": "7.0.0", 
    "npm": "3.10.8" 
    } 
} 
+0

对不起,我仍然无法使其与 “引擎” 的工作:{ “节点”: “7.0.0”, “故宫”: “4.0.2” }了建议吗?错误和以前一样 –

+0

是你的完整代码吗? – Vishnu

+0

@ Munkh-ErdeneErdenebileg正确的npm版本7.0.0是3.10.8。 检查更新的代码。 – Vishnu