node.js – Sequelize’方言需要从v4.0.0开始明确提供’

前端之家收集整理的这篇文章主要介绍了node.js – Sequelize’方言需要从v4.0.0开始明确提供’前端之家小编觉得挺不错的,现在分享给大家,也给大家做个参考。
我需要在node.js环境中运行第三方应用程序,但是Sequelize抛出的’Dialect需要从v4.0.0开始明确提供’
我在这里找到类似的话题 Dialect needs to be explicitly supplied as of v4.0.0,但’export NODE_ENV = development’不起作用,我找不到Sequelize配置文件.
我该如何解决这个错误

这是代码

const Sequelize = require('sequelize');

const scheme = require('./scheme');

const Op = Sequelize.Op;

const sequelize = new Sequelize(null,null,{

dialect: 'sqlite',storage: 'db.sqlite3',operatorsAliases: { $and: Op.and },logging: false
});

scheme(sequelize);
sequelize.sync();

module.exports.sequelize = sequelize;
module.exports.models = sequelize.models;

解决方法

你只需在初始化sequelize时提供方言;
const sequelize = new Sequelize('database','username','password',{
  host: 'localhost',dialect: // pick one of 'MysqL','sqlite','postgres','mssql',});

猜你在找的Node.js相关文章