mirror of
https://github.com/angular/angular
synced 2026-05-24 09:28:37 +00:00
- update `errors.ts` to annotate the error NG0403, so that the runtime can add a link to that guide when an error is thrown - update `application_ref_spec.ts` to include the new link of the error - update `errors.md` as a result of running `yarn bazel test packages/core/test` Fixes #47985 PR Close #48483
42 lines
1.6 KiB
Markdown
42 lines
1.6 KiB
Markdown
@name Bootstrapped NgModule doesn't specify which component to initialize
|
|
@category runtime
|
|
@shortDescription An NgModule that was used for bootstrapping does not specify which component should be initialized.
|
|
|
|
@description
|
|
This error means that an NgModule that was used for bootstrapping an application is missing key information for Angular to proceed with the bootstrap process.
|
|
|
|
The error happens when the NgModule `bootstrap` property is missing (or is an empty array) in the `@NgModule` annotation and there is no `ngDoBootstrap` lifecycle hook defined on that NgModule class.
|
|
|
|
More information about the bootstrapping process can be found in [this guide](guide/bootstrapping).
|
|
|
|
The following examples will trigger the error.
|
|
|
|
```typescript
|
|
@NgModule({
|
|
declarations: [AppComponent],
|
|
imports: [BrowserModule, AppRoutingModule],
|
|
providers: [],
|
|
})
|
|
export class AppModule {}
|
|
|
|
// The `AppModule` is used for bootstrapping, but the `@NgModule.bootstrap` field is missing.
|
|
platformBrowser().bootstrapModule(AppModule);
|
|
```
|
|
|
|
```typescript
|
|
@NgModule({
|
|
declarations: [AppComponent],
|
|
imports: [BrowserModule, AppRoutingModule],
|
|
providers: [],
|
|
bootstrap: [],
|
|
})
|
|
export class AppModule {}
|
|
|
|
// The `AppModule` is used for bootstrapping, but the `@NgModule.bootstrap` field contains an empty array.
|
|
platformBrowser().bootstrapModule(AppModule);
|
|
```
|
|
|
|
@debugging
|
|
Please make sure that the NgModule that is used for bootstrapping is setup correctly:
|
|
- either the `bootstrap` property exists (and contains a non-empty array) in the `@NgModule` annotation
|
|
- or the `ngDoBootstrap` method exists on the NgModule class
|