-
-
Notifications
You must be signed in to change notification settings - Fork 7.5k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Support for DynamicModule in NestFactory.create #671
Comments
Could you share your code please ? |
@adrien2p Well, this is related to nestjs/typeorm#24. There is an example there without the config part. Provider only seems to work, but nested dynamic module throw an exception when trying to inject services from them. I looked a bit and the dependency injection wrapper had undefined entries. |
Humm i see :) |
I have this issue as well and played around with it for what will make the following error appear:
ReproI've created a repro repo based on the CLI scaffold. To see the error, just run Basic SetupWhat is needed for this error to occur is a dependency between modules, as well as passing a dynamic module to So I created the ObservationFirst I thought that the import in Of course, you can also make this work by removing the dynamic module and importing |
Hey ! @Module({
providers: [
AppService,
],
controllers: [
AppController,
],
})
export class AppModule {
static dynamic(): DynamicModule {
return {
module: AppModule,
imports: [
LibraryModule,
DependentModule,
],
};
}
} |
Yes, if you comment this line that works because you don't use any thing else from the |
your issue is not related to this one |
@adrien2p The only thing I have changed in this branch is that instead of using a dynamic module in So as far as I can see, my issue is that |
humm, Yes you right i didn't notice that ^^ |
Okay, i think that i know where the problem come from The method |
I'm getting the same error when I upgraded from Nest 4.x.x to 5.x.x. Whats the state of this? Is this going to be fixed or is there another way? Angular Universal also does not support dynamic modules while bootstrapping but it provides a way to add providers while bootstrapping: app.engine('html', ngExpressEngine({
bootstrap: AppServerModuleNgFactory,
providers: [
{ provide: SOME_TOKEN, useValue: process.env.THING_YOU_CARE_ABOUT },
]
})); With Nest I could imagine something like this: await NestFactory.create(AppModule, {
providers: [
{ provide: SOME_TOKEN, useValue: process.env.THING_YOU_CARE_ABOUT },
]
}); Do not care whether dynamic modules are supported or the angular universal approach (prefer dynamic module though). Because of this error I am not able to upgrade to 5.x.x which is really unfortunate... |
That is not yet supported. |
bugfix(@nestjs/core) enable dynamic modules recursive imports #671
5.2.0 is here! |
This thread has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs. |
I'm submitting a...
Current behavior
DynamicModule are not supported by NestFactory create method.
Expected behavior
Support DynamicModule in NestFactory.create
What is the motivation / use case for changing the behavior?
I want to pass a configuration object to my application module and provide it there. I load it in the bootstrap method to get the port from the configuration.
Environment
The text was updated successfully, but these errors were encountered: