1
我想在Heroku託管的nodejs服務器應用程序中使用postgresql數據庫。在使用postgres模塊和nodejs和heroku時在pg-pool模塊中出錯
這是app.js我爲PG代碼:
var pg = require('pg');
pg.defaults.ssl = true;
pg.connect(process.env.DATABASE_URL, function(err, client) {
if (err) throw err;
console.log('Connected to postgres!');
});
和NPM聲明文件的package.json:
{
"name": "utility-app",
"version": "0.0.1",
"dependencies":
{
"ejs": "*",
"express": "3.3.x",
"pg": "6.0.1",
"simple-oauth2": "^0.7.0"
},
"engines":
{
"node": "0.10.x",
"npm": "1.2.x"
}
}
這是工作在我的本地環境,但是當我推碼到Heroku的服務器崩潰:
Screenshot of console demonstrating the crash
ŧ漢克你的幫助,
JP