1

In auth module am trying to access userservice class from usermodule, am getting error like cannot find module src/user/user.service Please find sample code ---

Thanks in advance.

Auth Module

@Module({
    imports : [UserModule],
    controllers: [AuthController],
    providers: [JwtStrategy, AuthService],
    exports : [JwtStrategy, AuthService]
})
export class AuthModule {}

UserModule

@Module({
    imports : [ MongooseModule.forFeature([{ name : 'User', schema : UserSchema }])],
    controllers: [UserController],
    providers: [UserService],
    exports : [UserService, MongooseModule.forFeature([{ name : 'User', schema : UserSchema }])]
})
export class UserModule {} 

AppModule

  imports: [
          AuthModule,
          UserModule,
          MongooseModule.forRoot('--',
          )],
  controllers: [AppController],
  providers: [AppService]
})
export class AppModule {}

1 Answer 1

5

Try to replace src/ with ../ or any relative path that you have with navigating to that path, with ./ or ../ it happens a lot when you auto-import some file. Also, you can export User service in User module, and place it (UserService) in Auth providers without importing whole module.

Sign up to request clarification or add additional context in comments.

1 Comment

Hi Rambabu,please accept the answers, if it works for you. :)

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.