林學習節點,並試圖創建一個使用快速的服務器並將其連接到一個Postgres數據庫,並不斷收到下面當我運行節點server.js:得到錯誤試圖Node.js的創建的Postgres數據庫
events.js:72
throw er; // Unhandled 'error' event
^
error: role "username" does not exist
at Connection.parseE (/Users/rs/Desktop/Jobletics/node_modules/pg/lib/connection.js:526:11)
at Connection.parseMessage (/Users/rs/Desktop/Jobletics/node_modules/pg/lib/connection.js:356:17)
at Socket.<anonymous> (/Users/rs/Desktop/Jobletics/node_modules/pg/lib/connection.js:105:22)
at Socket.emit (events.js:95:17)
at Socket.<anonymous> (_stream_readable.js:764:14)
at Socket.emit (events.js:92:17)
at emitReadable_ (_stream_readable.js:426:10)
at emitReadable (_stream_readable.js:422:5)
at readableAddChunk (_stream_readable.js:165:9)
at Socket.Readable.push (_stream_readable.js:127:10)
我的server.js文件看起來像這樣:
// app dependencies
var express = require("express");
var Sequelize = require("sequelize");
var bodyParser = require('body-parser');
var morgan = require('morgan');
var app = express();
//middleware
app.use(bodyParser());
app.use(morgan('dev'));
//sequalize initialization
var sequelize = new Sequelize("postgres://username:[email protected]:5432/jobletics");
var employerRoute = require("./routes/employer")(sequelize);
//sync the model with the database
sequelize.sync().success(function (err) {
app.get("/employer", employerRoute.get);
app.post("/employer", employerRoute.create);
app.listen(5000);
});
我有postgres運行。我是否需要在命令行中創建一個新的數據庫,然後運行$ psql來創建用戶名/密碼?不應該自動創建數據庫?
能否請你解釋一下,你是怎麼做的:「當我使用sequelize.js,我通常內運行vm,它有一個木偶清單來聲明數據庫已經存在。「 – rahul2001 2015-03-03 18:02:54