基本上,我在Heroku上部署了一个应用程序。现在,我正在尝试连接ClearDB附加组件,但有一些奇怪的错误。
这是我的Heroku配置:
C:\Users\GDrAnimal\Self-Project\Facebook Bot>heroku config
=== arcane-forest-17003 Config Vars
DATABASE_URL: mysql://b9490a25809735:37eb78b5@us-cdbr-iron-east-05.cleardb.net/heroku_1d0d2358c241fd0?reconnect=true
这是我使用Nodejs的代码
var mysql = require('mysql');
//Database
var connection = mysql.createConnection({
host: "us-cdbr-iron-east-05.cleardb.net",
user: "b9490a25809735",
password: "37eb78b5"
database: 'heroku_1d0d2358c241fd0'
});
connection.connect();
app.get('/', (req, res) => {
connection.query('SELECT * from Student_Bot', function(err, rows, fields) {
if (err) {
console.log('Error Reported ', err);
throw err;
}
res.send(['Hello World!!!! HOLA MUNDO!!!!', rows]);
});
});
然而,当我尝试打开我的应用时,它已经崩溃了...... 这是我的Heroku日志:
2017-10-11T03:29:02.994422+00:00 app[web.1]: SyntaxError: Unexpected
identifier
2017-10-11T03:29:02.994423+00:00 app[web.1]: at createScript
(vm.js:56:10)
2017-10-11T03:29:02.994423+00:00 app[web.1]: at Object.runInThisContext (vm.js:97:10)
2017-10-11T03:29:02.994424+00:00 app[web.1]: at Module._compile (module.js:542:28)
2017-10-11T03:29:02.994425+00:00 app[web.1]: at Object.Module._extensions..js (module.js:579:10)
2017-10-11T03:29:02.994426+00:00 app[web.1]: at Module.load (module.js:487:32)
2017-10-11T03:29:02.994426+00:00 app[web.1]: at tryModuleLoad (module.js:446:12)
2017-10-11T03:29:02.994427+00:00 app[web.1]: at Function.Module._load (module.js:438:3)
2017-10-11T03:29:02.994427+00:00 app[web.1]: at Module.runMain (module.js:604:10)
2017-10-11T03:29:02.994428+00:00 app[web.1]: at run (bootstrap_node.js:383:7)
2017-10-11T03:29:02.994429+00:00 app[web.1]: at startup (bootstrap_node.js:149:9)
2017-10-11T03:29:03.094049+00:00 heroku[web.1]: Process exited with status 1
2017-10-11T03:29:03.109659+00:00 heroku[web.1]: State changed from starting to crashed
2017-10-11T03:29:03.113306+00:00 heroku[web.1]: State changed from crashed to starting
2017-10-11T03:29:04.742139+00:00 heroku[web.1]: Starting process with command `node bot.js`
2017-10-11T03:29:07.004884+00:00 app[web.1]: /app/bot.js:27
2017-10-11T03:29:07.004904+00:00 app[web.1]: database: 'heroku_1d0d2358c241fd0'
2017-10-11T03:29:07.004905+00:00 app[web.1]: ^^^^^^^^
2017-10-11T03:29:07.004905+00:00 app[web.1]:
2017-10-11T03:29:07.004906+00:00 app[web.1]: SyntaxError: Unexpected identifier
2017-10-11T03:29:07.004907+00:00 app[web.1]: at createScript (vm.js:56:10)
2017-10-11T03:29:07.004907+00:00 app[web.1]: at Object.runInThisContext (vm.js:97:10)
2017-10-11T03:29:07.004908+00:00 app[web.1]: at Module._compile (module.js:542:28)
2017-10-11T03:29:07.004909+00:00 app[web.1]: at Object.Module._extensions..js (module.js:579:10)
2017-10-11T03:29:07.004909+00:00 app[web.1]: at Module.load (module.js:487:32)
2017-10-11T03:29:07.004910+00:00 app[web.1]: at tryModuleLoad (module.js:446:12)
2017-10-11T03:29:07.004910+00:00 app[web.1]: at Function.Module._load (module.js:438:3)
2017-10-11T03:29:07.004911+00:00 app[web.1]: at Module.runMain (module.js:604:10)
2017-10-11T03:29:07.004912+00:00 app[web.1]: at run (bootstrap_node.js:383:7)
2017-10-11T03:29:07.004912+00:00 app[web.1]: at startup (bootstrap_node.js:149:9)
2017-10-11T03:29:07.086015+00:00 heroku[web.1]: State changed from starting to crashed
2017-10-11T03:29:07.070905+00:00 heroku[web.1]: Process exited with status 1
2017-10-11T04:05:26.000000+00:00 app[api]: Build started by user gdranimal123@gmail.com
2017-10-11T04:05:36.046510+00:00 app[api]: Release v47 created by user gdranimal123@gmail.com
2017-10-11T04:05:36.046510+00:00 app[api]: Deploy 1366f9f3 by user gdranimal123@gmail.com
2017-10-11T04:05:36.525080+00:00 heroku[web.1]: State changed from crashed to starting
答案 0 :(得分:1)
你的变量人没有逗号。
password: "37eb78b5"<missing comma>
database: 'heroku_1d0d2358c241fd0'
下次您可以看到错误日志并进行调试。
2017-10-11T03:29:07.004884 + 00:00 app [web.1]:/app/bot.js:27 2017-10-11T03:29:07.004904 + 00:00 app [web.1]:数据库: &#39; heroku_1d0d2358c241fd0&#39;