简体   繁体   中英

Error while deploying to Google App Engine

I am trying to deploy an application to Google App Engine. Its a Node.js application with MySQL Backend. I am using Sequelize ORM. Both the Cloud SQL Instance and the App Engine are in the same project. When I try to deploy and start the application I am getting the following error.

Updating service [default] (this may take several minutes)...failed.
ERROR: (gcloud.app.deploy) Error Response: [9]
Application startup error:

> teachhub@1.0.0 start /app
> node server

/app/node_modules/sequelize/lib/sequelize.js:236
        throw new Error('The dialect ' + this.getDialect() + ' is not supported. Supported dialects: mssql, mysql, postgres, and sqlite.');
        ^

Error: The dialect my-nodejs-codelab-1217-190421 is not supported. Supported dialects: mssql, mysql, postgres, and sqlite.
    at new Sequelize (/app/node_modules/sequelize/lib/sequelize.js:236:15)
    at Object.<anonymous> (/app/models/index.js:13:18)
    at Module._compile (module.js:652:30)
    at Object.Module._extensions..js (module.js:663:10)
    at Module.load (module.js:565:32)
    at tryModuleLoad (module.js:505:12)
    at Function.Module._load (module.js:497:3)
    at Module.require (module.js:596:17)
    at require (internal/module.js:11:18)
    at Object.<anonymous> (/app/routes/apiRoutes.js:1:72)
    at Module._compile (module.js:652:30)
    at Object.Module._extensions..js (module.js:663:10)
    at Module.load (module.js:565:32)
    at tryModuleLoad (module.js:505:12)
    at Function.Module._load (module.js:497:3)
    at Module.require (module.js:596:17)
    at require (internal/module.js:11:18)
    at Object.<anonymous> (/app/server.js:3:14)
    at Module._compile (module.js:652:30)
    at Object.Module._extensions..js (module.js:663:10)
    at Module.load (module.js:565:32)
    at tryModuleLoad (module.js:505:12)
npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! teachhub@1.0.0 start: `node server`
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the teachhub@1.0.0 start script.
npm ERR! This is probably not a problem with npm. There is likely additional logging output above.
npm ERR! A complete log of this run can be found in:
npm ERR!     /root/.npm/_logs/2018-07-08T15_03_28_369Z-debug.log

Given below is my models/index.js...

"use strict";
var fs = require("fs");
var path = require("path");
var Sequelize = require("sequelize");
var basename = path.basename(module.filename);
var env = process.env.NODE_ENV || "development";
let keys = require(__dirname + "/../config/config.js");
keys = keys.dbConfig[env];
var db = {};
if(process.env.INSTANCE_CONNECTION_NAME){
        var sequelize = new Sequelize(process.env.INSTANCE_CONNECTION_NAME, {dialect:"mysql"});
} else if (process.env.JAWSDB_URL) {
  var sequelize = new Sequelize(process.env.JAWSDB_URL);
} else if (keys.use_env_variable) {
  var sequelize = new Sequelize(process.env[keys.use_env_variable], keys);
} else {
  var sequelize = new Sequelize(
    keys.database,
    keys.username,
    keys.password,
    keys
  );
}

Can someone please help?

It seems that it is missing a definition to the sequelize dialect. In your case 'key.dialect', assuming that you have defined the dialect in your config file. The dialect defines the kind of database used on your project as you can confirm in the following documentation: http://docs.sequelizejs.com/manual/installation/usage.html

In the Documentation:

const sequelize = new Sequelize({
database: 'db_name',
username: 'username',
password: null,
dialect: 'mysql'
});

In your code:

enter codvar sequelize = new Sequelize( 
Keys.database,
keys.username, 
keys.password, 
keys.dialect
);

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM