首页 > 解决方案 > node-postgres:数据库“database_name”不存在错误

问题描述

我正在使用PERN(postgres,express,react,node)构建REST API。我正在尝试在邮递员上测试我的用户注册路线,当我发送请求时出现此错误。“数据库 [我的数据库名称] 不存在”

我检查了 postgres 服务器,我可以清楚地看到我拥有数据库并创建了它。这是我的联系。

const Pool = require("pg").Pool


const pool = new Pool({
    host: "localhost",
    user: "[myuser]",
    password: "[mypassword]",
    port: 5432,
    database: "rental"
})


module.exports = pool;
      Name      |     Owner      | Encoding |   Collate   |    Ctype    |   Access privileges   
----------------+----------------+----------+-------------+-------------+-----------------------
 lucasleiberman | lucasleiberman | UTF8     | en_US.UTF-8 | en_US.UTF-8 | 
 postgres       | postgres       | UTF8     | en_US.UTF-8 | en_US.UTF-8 | 
 rental         | lucasleiberman | UTF8     | en_US.UTF-8 | en_US.UTF-8 | 
 rentalapp      | lucasleiberman | UTF8     | en_US.UTF-8 | en_US.UTF-8 | 
 template0      | postgres       | UTF8     | en_US.UTF-8 | en_US.UTF-8 | =c/postgres       

标签: node.jspostgresqlexpress

解决方案


推荐阅读