1. 程式人生 > 其它 >Dialect needs to be explicitly supplied as of v4.0.0

Dialect needs to be explicitly supplied as of v4.0.0

技術標籤:vuenode.jsmysqlsql

使用sequelize,初始化時報錯 Dialect needs to be explicitly supplied as of v4.0.0

C:\Users\11783\Desktop\tocity-service\node_modules\sequelize\lib\sequelize.js:281
      throw new Error('Dialect needs to be explicitly supplied as of v4.0.0');
      ^

Error: Dialect needs to be explicitly supplied as
of v4.0.0 at new Sequelize (C:\Users\11783\Desktop\tocity-service\node_modules\sequelize\lib\sequelize.js:281:13) at Object.<anonymous> (C:\Users\11783\Desktop\tocity-service\app.js:11:19) at Module._compile (internal/modules/cjs/loader.js:959:30) at Object.Module._extensions..js (internal/
modules/cjs/loader.js:995:10) at Module.load (internal/modules/cjs/loader.js:815:32)

解決方案

const sequelize = new Sequelize('database', 'username', 'password', {
  host: 'localhost',
  dialect: /* 選擇 'mysql' | 'mariadb' | 'postgres' | 'mssql' 其一 */
});

之前沒有使用dialect指明具體資料庫所以出錯