简体   繁体   中英

Next.js prisma recipe - ERROR [ExceptionHandler] Nest can't resolve dependencies of the AppController (?, PostService)

I followed the recipe on https://docs.nestjs.com/recipes/prisma (twice) and I get the following error:

ERROR [ExceptionHandler] Nest can't resolve dependencies of the AppController (?, PostService). Please make sure that the argument UserService at index [0] is available in the AppModule context.

when starting with npm start.

The only thing I have changed from the recipe is in the last block of code where I changed import { PrismaService } from './services/prisma/prisma.service';

to

import { PrismaService } from './prisma.service';

beacause prisma.service isn't located at that location.

I don't know what to do to fix it. I would have expected a guide on the official site to work.

I changed app.module.ts into this:

import { Module } from '@nestjs/common';
import { AppController } from './app.controller';
import { UserService } from './user.service';
import { PostService } from './post.service';
import { PrismaService } from './prisma.service';


@Module({
  imports: [],
  controllers: [AppController],
  providers: [UserService, PostService, PrismaService],
})
export class AppModule {}

Now it works.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM