Javascript Node.js-TypeError:客户端不是构造函数
我正在尝试以下方法:Javascript Node.js-TypeError:客户端不是构造函数,javascript,node.js,postgresql,Javascript,Node.js,Postgresql,我正在尝试以下方法: const { Client } = require('pg'); console.log(Client); const client = new Client({ user: 'Username censored', host: 'Host censored', database: 'gisuebung', password: 'Passworded censored', port: 5432,
const { Client } = require('pg');
console.log(Client);
const client = new Client({
user: 'Username censored',
host: 'Host censored',
database: 'gisuebung',
password: 'Passworded censored',
port: 5432,
});
client.connect();
然而,当我运行这个程序时,我得到了以下错误:v-on处理程序中的错误:“TypeError:Client不是构造函数”
我在网上找到一个片段后写下了这篇文章,我看到的每个地方人们都做了同样的事情。谁能告诉我我做错了什么吗?信息不够。这可能是许多不同的事情,但最有可能是版本问题,即pg依赖性。查看您使用的版本,因为这似乎是一个常见问题版本2.0~它对我很有效,因此请尝试检查您的依赖关系,或将您的const name从
client
更改为类似pgClient
的内容,以检查destructuringworked是否也对我有效!“v-on处理程序”指的是什么?我正在使用Vue.js,所以v-on处理程序就是从那里来的