簡體   English   中英

錯誤:數據庫“dbName”不存在 Node.js PostgreSQL

[英]error: database "dbName" does not exist Node.js PostgreSQL

我剛從 Node.js 開始,我正在關注本教程https://dev.to/glaucia86/developing-a-crud-node-js-application-with-postgresql-4c9o

按照建議設置.env文件時

DATABASE_URL=postgres://{db_username}:{db_password}@{host}:{port}/{db_name}

所以


DATABASE_URL=postgres://vinnytwice:pass@localhost:5432/fixit

當使用 Postman 發送 Post 請求時,我使用npm start命令啟動服務器,我在控制台中收到錯誤消息:

vinnytwice@Vinnys-iMac fixit_server_node % npm start

> fixit_server_node@1.0.0 start
> node server.js

App executing to port  3000
error: database "vinnytwice" does not exist
    at Parser.parseErrorMessage (/Volumes/ProjectsSSD/FixitServer/fixit_server_node/node_modules/pg-protocol/dist/parser.js:287:98)
    at Parser.handlePacket (/Volumes/ProjectsSSD/FixitServer/fixit_server_node/node_modules/pg-protocol/dist/parser.js:126:29)
    at Parser.parse (/Volumes/ProjectsSSD/FixitServer/fixit_server_node/node_modules/pg-protocol/dist/parser.js:39:38)
    at Socket.<anonymous> (/Volumes/ProjectsSSD/FixitServer/fixit_server_node/node_modules/pg-protocol/dist/index.js:11:42)
    at Socket.emit (node:events:369:20)
    at addChunk (node:internal/streams/readable:313:12)
    at readableAddChunk (node:internal/streams/readable:288:9)
    at Socket.Readable.push (node:internal/streams/readable:227:10)
    at TCP.onStreamRead (node:internal/stream_base_commons:190:23)

我究竟做錯了什么? 非常感謝。

終於找到問題了, .env文件不在項目的根目錄下。

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM