0

I've initiated a TypeORM module, I'm trying to run using npm run start:dev but then i get and error that says a role named after my Windows user was not found

error: role "Itay" does not exist

then followed by the stack trace:

    at Parser.handlePacket (C:\Users\Itay\Desktop\steam clone\steamclone\node_modules\pg-protocol\src\parser.ts:188:21)
    at Parser.parse (C:\Users\Itay\Desktop\steam clone\steamclone\node_modules\pg-protocol\src\parser.ts:103:30)
    at Socket.<anonymous> (C:\Users\Itay\Desktop\steam clone\steamclone\node_modules\pg-protocol\src\index.ts:7:48)
    at Socket.emit (events.js:400:28)
    at addChunk (internal/streams/readable.js:293:12)
    at readableAddChunk (internal/streams/readable.js:267:9)
    at Socket.Readable.push (internal/streams/readable.js:206:10)
    at TCP.onStreamRead (internal/stream_base_commons.js:188:23) ```

The module:

import { Module } from '@nestjs/common';
import { TypeOrmModule } from '@nestjs/typeorm';
import {ConfigModule, ConfigService} from '@nestjs/config';

@Module({
    imports: [
        TypeOrmModule.forRootAsync({
            imports: [ConfigModule],
            inject: [ConfigService],
            useFactory: (ConfigService: ConfigService) => ({
                type: 'postgres',
                host: ConfigService.get('DB_HOST'),
                port: ConfigService.get('DB_PORT'),
                username: ConfigService.get('DB_USER'),
                password: ConfigService.get('DB_PASSWORD'),
                database: ConfigService.get('DB_DATABASE'),
                entities: [__dirname + '/../**/*.entity{.ts,.js}'],
                synchronize: true,
            })
        })
    ],
})
export class DatabaseModule {}

I tried deleting the whole project, then recreating it a few times.. nothing seems to help. I'm seriously considering using Prisma instead up to this point

Itay Haim
  • 69
  • 3
  • looks like a misconfiguration in your postgresql server https://stackoverflow.com/questions/11919391/postgresql-error-fatal-role-username-does-not-exist I believe this isn't related to TypeORM – Micael Levi Mar 13 '22 at 20:39
  • I've looked into it - created a user and elevated his access privileges, ` Role name | Attributes | Member of -----------+------------------------------------------------------------+----------- Itay | Superuser, Create role, Create DB | {} postgres | Superuser, Create role, Create DB, Replication, Bypass RLS | {} ` the other issue is the ORM can't find a database named after the role- though the code provided does not point to a database called like that – Itay Haim Mar 14 '22 at 23:28

0 Answers0