在heroku应用程序中连接MySQL数据库时出错的类型

在heroku应用程序中连接MySQL数据库时出错的类型,mysql,node.js,heroku,Mysql,Node.js,Heroku,我已经试着让我的heroku应用程序正常工作好几个小时了,我不知道该怎么做了。我收到错误:TypeError:pool.promise不是函数。奇怪的是,在开发环境中,我的笔记本电脑上的一切都很好 My database.js文件包含以下代码: const mysql = require('mysql2/promise'); const config = require('config'); const pool = mysql.createPool({ host: 'us-cdbr-ir

我已经试着让我的heroku应用程序正常工作好几个小时了,我不知道该怎么做了。我收到错误:TypeError:pool.promise不是函数。奇怪的是,在开发环境中,我的笔记本电脑上的一切都很好

My database.js文件包含以下代码:

const mysql = require('mysql2/promise');
const config = require('config');

const pool = mysql.createPool({
  host: 'us-cdbr-iron-east-05.cleardb.net',
  user: 'b5ab7f7c8bed47',
  database: 'heroku_d28016f0657fae1',
  password: process.env.db_pass,
});

module.exports = pool.promise();   <---- This line recieves the Typeof error.
constmysql=require('mysql2/promise');
const config=require('config');
constpool=mysql.createPool({
主持人:“us-cdbr-iron-east-05.cleardb.net”,
用户:“b5ab7f7c8bed47”,
数据库:“heroku_d28016f0657fae1”,
密码:process.env.db_pass,
});

module.exports=pool.promise();确保
require
语句中的路径正确。它们在开发环境中可能不同。我上面的评论有帮助吗?谢谢你的评论。我检查了路径,它们是对的(我想)。我不断遇到的下一个错误是关于承诺没有catch方法并抛出错误。错误表明它来自mysql2模块。我最终卸载了mysql2并安装了mysql。我使用了回调,一切正常。