Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/javascript/395.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Javascript pg承诺类型错误:无效;选项“;参数_Javascript_Express_Pg Promise - Fatal编程技术网

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;

你没有遵循规则,因此出现了错误。你是对的!今天早些时候我把所有的东西都扔掉了,从零开始整理你的资源,这一点变得显而易见。