postgresql Postgres 方言在 sequelize -m 中不起作用
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/22083223/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
Postgres dialect not working in sequelize -m
提问by pjbr
Running Sequelize -m
运行 Sequelize -m
in my config.json
在我的 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?
我的配置是否有问题,或者其他可能是问题的地方?
回答by Dima Knivets
I've stumbled upon the same problem. You should install pg
module globally. Here's the command:
我偶然发现了同样的问题。您应该pg
全局安装模块。这是命令:
npm install -g pg
回答by Joseph Juhnke
Nope!
不!
You need to install pg-hstore.
您需要安装 pg-hstore。
See here: https://github.com/sequelize/sequelize/issues/2949
回答by Morteza Shahriari Nia
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.
还要单独创建数据库,sequelize 不会为您创建数据库。
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'
});
});
回答by jrvidotti
I've run npm install --save pg
inside sequelize directory and everything is fine now.
我已经npm install --save pg
在 sequelize 目录中运行了,现在一切都很好。
回答by Ramesh Chand
I have run root@# "npm install pg pg-hstore sequelize --save" and it resolve the issue for me. Thanks !
我已经运行了 root@# " npm install pg pg-hstore sequelize --save" 它为我解决了这个问题。谢谢 !
回答by Str.
The doc says:
医生说:
With the release of Sequelizev1.6.0, the library got independent from specific dialects. That mean, that you'll have to add the respective dialect library yourself. Another option is the use of the sequelize packages that ship the dialect libraries as well.
随着 Sequelizev1.6.0 的发布,该库独立于特定的方言。这意味着,您必须自己添加相应的方言库。另一种选择是使用附带方言库的 sequelize 包。
Then you might have missed to require the library, see Sequelize docs.
那么您可能错过了对库的需求,请参阅Sequelize docs。
回答by Hakkar
Did an strace on the application. It seems Sequelize v2.x was searching for 'pg-native.
对应用程序进行了跟踪。似乎 Sequelize v2.x 正在搜索“pg-native”。
npm install -g pg-native
npm install -g pg-native