#Why do I need to use module.forRoot(...) everywhere I need the module?
8 messages · Page 1 of 1 (latest)
forRoot is supposed to be used only in the root module, you know
show us an use case, please
so I have this in my app & other module
imports: [
TwilioModule.forRoot({
accountSid: process.env.TWILIO_ACCOUNT_SID,
authToken: process.env.TWILIO_AUTH_TOKEN,
}),
],```
it works if I leave it in the module I need it
but in app alone I get:
Potential solutions:
- Is TwilioApiModule a valid NestJS module?
- If TwilioService is a provider, is it part of the current TwilioApiModule?
- If TwilioService is exported from a separate @Module, is that module imported within TwilioApiModule?
I tho that importing it in app.module was enough
if app alone + service imported in the needed module, I get:
[Error]: Nest can't resolve dependencies of the TwilioService (?). Please make sure that the argument "CONFIGURABLE_MODULE_OPTIONS[f5ea03a39f2a16943678c]" at index [0] is available in the TwilioApiModule context.
Potential solutions:
- Is TwilioApiModule a valid NestJS module?
- If "CONFIGURABLE_MODULE_OPTIONS[f5ea03a39f2a16943678c]" is a provider, is it part of the current TwilioApiModule?
- If "CONFIGURABLE_MODULE_OPTIONS[f5ea03a39f2a16943678c]" is exported from a separate @Module, is that module imported within TwilioApiModule?
@Module({
imports: [ /* the Module containing "CONFIGURABLE_MODULE_OPTIONS[f5ea03a39f2a16943678c]" */ ]
})
so if imported from app.mobule, how to use its service?
I think setting global to true fixed the issue