'Nest.JS TypeORM "SCRAM-SERVER-FIRST-MESSAGE: client password must be a string"

I dont know why, but since I was cloning my working repository I am using on AWS to a local machine and try to run it, I am getting the following error:

"SCRAM-SERVER-FIRST-MESSAGE: client password must be a string"

Error: SASL: SCRAM-SERVER-FIRST-MESSAGE: client password must be a string
at Object.continueSession (C:\Users\thehe\Documents\workspace\work\nft-trading-server\node_modules\pg\lib\sasl.js:24:11)
at Client._handleAuthSASLContinue (C:\Users\thehe\Documents\workspace\work\nft-trading-server\node_modules\pg\lib\client.js:257:10)
at Connection.emit (node:events:390:28)
at C:\Users\thehe\Documents\workspace\work\nft-trading-server\node_modules\pg\lib\connection.js:114:12
at Parser.parse (C:\Users\thehe\Documents\workspace\work\nft-trading-server\node_modules\pg-protocol\src\parser.ts:104:9)
at Socket.<anonymous> (C:\Users\thehe\Documents\workspace\work\nft-trading-server\node_modules\pg-protocol\src\index.ts:7:48)
at Socket.emit (node:events:390:28)
at addChunk (node:internal/streams/readable:315:12)
at readableAddChunk (node:internal/streams/readable:289:9)
at Socket.Readable.push (node:internal/streams/readable:228:10)
at TCP.onStreamRead (node:internal/stream_base_commons:199:23)

POSTGRES_HOST=localhost
POSTGRES_PORT=5432
POSTGRES_USER=admin
POSTGRES_PASSWORD=admin
POSTGRES_DB=nftapi01
PORT=5000

Does anyone know where that is coming from and how to fix this? I am not sure why I get this locally. I can connect to the pg database with the credentials of the .dev.env file but the Nest app wont start.



Solution 1:[1]

Are you importing the "dotenv" package? you need it for access to environment variables. On your server.js file put: require('dotenv').config();

You said that you cloned your repository... do you have a package.json file in your project? (inside this file you declare what is your main file: "main": "server.js")

Of course, you need access to read your .env file, check them!

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 Fabio Suarez