我已经到了终点,我正在尝试将我的应用程序上传到生产环境。我运行了ng build --prod命令,但只收到一条警告消息:
"WARNING in Circular dependency detected:
src\app\app.module.ts -> src\app\app.module.ngfactory.js -> src\app\app.module.ts"
似乎这只是一个警告,但我不太确定可能是导致此错误的原因;我在应用程序中遇到的主要错误是:
main-es2015.39c9ec206581527dd6ff.js:1 Uncaught TypeError: Cannot read property 'moduleType' of undefined
这仅在生产环境中有效,在我的本地环境中也是如此。我在IIS服务器中安装了它。
我读到一篇文章angular没有给您所有错误,但是运行此命令会给您错误消息。我运行了它,但确实有一些错误可以解决。
./node_modules/.bin/ngc
我快到了...任何帮助将不胜感激,请告诉我是否还有其他我可以上传的数据或文件,以帮助您查明错误。
不确定这是否有帮助:
import { BrowserModule } from '@angular/platform-browser';
import { NgModule } from '@angular/core';
import { HttpClientModule } from '@angular/common/http';
import { AppRoutingModule } from './app-routing.module';
import { AppComponent } from './app.component';
import { TaskComponent } from './task/task.component';
import { HeaderComponent } from './header/header.component';
import { FooterComponent } from './footer/footer.component';
//services
import {TaskService} from './task.service';
import {AuthService} from './auth.service';
//material design
import {BrowserAnimationsModule} from '@angular/platform-browser/animations';
//reactive forms
import { FormsModule, ReactiveFormsModule } from '@angular/forms';
import { MatPasswordStrengthModule } from '@angular-material-extensions/password-strength';
import { MatAutocompleteModule } from '@angular/material/autocomplete';
import { MatBadgeModule } from '@angular/material/badge';
import { MatButtonModule } from '@angular/material/button';
import { MatCardModule } from '@angular/material/card';
import { MatCheckboxModule } from '@angular/material/checkbox';
import { MatDialogModule } from '@angular/material/dialog';
import { MatExpansionModule } from '@angular/material/expansion';
import { MatFormFieldModule } from '@angular/material/form-field';
import { MatGridListModule } from '@angular/material/grid-list';
import { MatIconModule } from '@angular/material/icon';
import { MatInputModule } from '@angular/material/input';
import { MatListModule } from '@angular/material/list';
import { MatMenuModule } from '@angular/material/menu';
import { MatPaginatorModule } from '@angular/material/paginator';
import { MatProgressBarModule } from '@angular/material/progress-bar';
import { MatProgressSpinnerModule } from '@angular/material/progress-spinner';
import { MatSelectModule } from '@angular/material/select';
import { MatSidenavModule } from '@angular/material/sidenav';
import { MatSlideToggleModule } from '@angular/material/slide-toggle';
import { MatSnackBarModule } from '@angular/material/snack-bar';
import { MatSortModule } from '@angular/material/sort';
import { MatStepperModule } from '@angular/material/stepper';
import { MatTableModule } from '@angular/material/table';
import { MatTabsModule } from '@angular/material/tabs';
import { MatToolbarModule } from '@angular/material/toolbar';
import { MatTooltipModule } from '@angular/material/tooltip';
import { MatTreeModule } from '@angular/material/tree';
import {platformBrowserDynamic} from '@angular/platform-browser-dynamic';
import { UpdateTaskComponent } from './update-task/update-task.component';
import { CreateTaskComponent } from './create-task/create-task.component';
import { RegisterComponent } from './register/register.component';
import { LoginComponent } from './login/login.component';
import { UpdateRecipientComponent } from './update-recipient/update-recipient.component';
import { CreateNewUserComponent } from './create-new-user/create-new-user.component';
import { SidenavService } from './sidenav.service';
import { ManageUsersComponent } from './manage-users/manage-users.component';
import { UpdateUserComponent } from './update-user/update-user.component';
import { ConfirmationDialogComponent } from './confirmation-dialog/confirmation-dialog.component';
import { TabDirective } from './ReuseableFunctions/tab-directive';
import { MyReportsGridComponent } from './my-reports-grid/my-reports-grid.component';
import { PageNotFoundComponent } from './page-not-found/page-not-found.component';
import { CdkDetailsRowDirective } from './cdk-details-row.directive';
@NgModule({
declarations: [
AppComponent,
CdkDetailsRowDirective,
TaskComponent,
HeaderComponent,
FooterComponent,
UpdateTaskComponent,
CreateTaskComponent,
RegisterComponent,
LoginComponent,
UpdateRecipientComponent,
CreateNewUserComponent,
ManageUsersComponent,
UpdateUserComponent,
ConfirmationDialogComponent,
TabDirective,
MyReportsGridComponent,
PageNotFoundComponent
],
imports: [
BrowserModule,
AppRoutingModule,
MatButtonModule,
MatCheckboxModule,
MatInputModule,
MatPaginatorModule,
MatProgressSpinnerModule,
MatSortModule,
MatTableModule,
MatCardModule,
MatListModule,
MatToolbarModule,
MatIconModule,
MatSidenavModule,
MatBadgeModule,
MatTooltipModule,
MatSelectModule,
MatDialogModule,
HttpClientModule,
BrowserAnimationsModule,
FormsModule,
ReactiveFormsModule,
MatTreeModule,
MatFormFieldModule,
MatSlideToggleModule,
MatAutocompleteModule,
MatTabsModule,
MatExpansionModule,
MatSnackBarModule,
MatStepperModule,
MatPasswordStrengthModule,
MatGridListModule,
MatProgressBarModule,
MatMenuModule
],
entryComponents: [UpdateTaskComponent, UpdateRecipientComponent, UpdateUserComponent, ConfirmationDialogComponent],
providers: [TaskService,AuthService, SidenavService, HeaderComponent],
bootstrap: [AppComponent]
})
export class AppModule { }
platformBrowserDynamic().bootstrapModule(AppModule);
答案 0 :(得分:0)
我遇到了类似的问题。对我来说,根本原因是我的app.module.ts
以下几行引起循环依赖。删除后,我不再面对这个问题
platformBrowserDynamic().bootstrapModule(AppModule);