Javascript pg承诺类型错误:无效;选项“;参数
我正在尝试将我的文件从使用Javascript pg承诺类型错误:无效;选项“;参数,javascript,express,pg-promise,Javascript,Express,Pg Promise,我正在尝试将我的文件从使用pg包更改为pg promise包。我使用的初始pg解决方案一切正常。但是,切换到pg promise并使用文档,我在设置过程中遇到了奇怪的错误 最新错误: throw new TypeError('Invalid "options" parameter: ' + JSON.stringify(options)); ^ TypeError: Invalid "options" parameter: "postgres://me:complete@localhost:54
pg
包更改为pg promise
包。我使用的初始pg
解决方案一切正常。但是,切换到pg promise
并使用文档,我在设置过程中遇到了奇怪的错误
最新错误:
throw new TypeError('Invalid "options" parameter: ' + JSON.stringify(options));
^
TypeError: Invalid "options" parameter: "postgres://me:complete@localhost:5432/education_be"
require('dotenv').config();
const pgp = require('pg-promise');
// === My initial setup just using 'pg'
// const { Pool } = require('pg');
// const pool = new Pool({
// name: process.env.name,
// password: process.env.password,
// host: process.env.host,
// database: 'education_be',
// port: process.env.port
// });
// === My first attempt following the guide would receive errors like:
// === Error: Option "user" is not recognized.
const connection = {
name: 'me',
password: 'password',
host: 'localhost',
database: 'education_be',
port: 5432
};
// === attempting (unsuccessfully) to just use the address
const db = pgp('postgres://me:complete@localhost:5432/education_be');
module.exports = db;
我的配置文件:
throw new TypeError('Invalid "options" parameter: ' + JSON.stringify(options));
^
TypeError: Invalid "options" parameter: "postgres://me:complete@localhost:5432/education_be"
require('dotenv').config();
const pgp = require('pg-promise');
// === My initial setup just using 'pg'
// const { Pool } = require('pg');
// const pool = new Pool({
// name: process.env.name,
// password: process.env.password,
// host: process.env.host,
// database: 'education_be',
// port: process.env.port
// });
// === My first attempt following the guide would receive errors like:
// === Error: Option "user" is not recognized.
const connection = {
name: 'me',
password: 'password',
host: 'localhost',
database: 'education_be',
port: 5432
};
// === attempting (unsuccessfully) to just use the address
const db = pgp('postgres://me:complete@localhost:5432/education_be');
module.exports = db;
你没有遵循规则,因此出现了错误。你是对的!今天早些时候我把所有的东西都扔掉了,从零开始整理你的资源,这一点变得显而易见。