Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Postgres dialect not working in sequelize -m

Running Sequelize -m

in my config.json

"development": {
    "username": "root",
    "password": null,
    "database": "**********",
    "dialect": "postgres",
    "protocol": "postgres",
    "port": 5432,
    "host": "127.0.0.1"
},

getting error:

sequelize -m
Loaded configuration file "config/config.json".
Using environment "development".

/usr/local/lib/node_modules/sequelize/lib/transaction-manager.js:10
    throw new Error("The dialect " + sequelize.getDialect() + " is not support
          ^
Error: The dialect postgres is not supported.
    at new module.exports (/usr/local/lib/node_modules/sequelize/lib/transaction-manager.js:10:11)
    at new module.exports.Sequelize (/usr/local/lib/node_modules/sequelize/lib/sequelize.js:128:31)
    at Object.<anonymous> (/usr/local/lib/node_modules/sequelize/bin/sequelize:225:27)
    at Module._compile (module.js:456:26)
    at Object.Module._extensions..js (module.js:474:10)
    at Module.load (module.js:356:32)
    at Function.Module._load (module.js:312:12)
    at Function.Module.runMain (module.js:497:10)
    at startup (node.js:119:16)
    at node.js:901:3

Is there a problem in my config, or something else that could be the issue?

like image 828
pjbr Avatar asked Feb 27 '14 23:02

pjbr


5 Answers

I've stumbled upon the same problem. You should install pg module globally. Here's the command:

npm install -g pg
like image 80
Dima Knivets Avatar answered Nov 18 '22 03:11

Dima Knivets


I have run root@# "npm install pg pg-hstore sequelize --save" and it resolve the issue for me. Thanks !

like image 28
Ramesh Chand Avatar answered Oct 27 '22 18:10

Ramesh Chand


Nope!

You need to install pg-hstore.

See here: https://github.com/sequelize/sequelize/issues/2949

like image 7
Joseph Juhnke Avatar answered Nov 18 '22 04:11

Joseph Juhnke


You need to have

$ npm install pg --save
$ npm install pg-hstore --save
$ npm install sequelize --save

Also create the database separately, sequelize doesn't create the db for you.

var Sequelize = require("sequelize");

// make sure you have created the database using pg Admin III 
var sequelize = new Sequelize("postgres://postgres:postgres@localhost:5432/yourdbname");

var Person = sequelize.define('person', {
  firstName: {
    type: Sequelize.STRING
  },
  lastName: {
    type: Sequelize.STRING
  }
});

Person.sync({force: true}).then(function () {
  return Person.create({
    firstName: 'jj',
    lastName: 'Hancock'
  });
});
like image 7
Morteza Shahriari Nia Avatar answered Nov 18 '22 03:11

Morteza Shahriari Nia


I've run npm install --save pg inside sequelize directory and everything is fine now.

like image 4
jrvidotti Avatar answered Nov 18 '22 04:11

jrvidotti