Reputation: 579
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 {}
Upvotes: 1
Views: 1752
Reputation: 96
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.
Upvotes: 5