Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
540 views
in Technique[技术] by (71.8m points)

javascript - “错误:参数数组必须具有参数。” AppModule(“Error: Arguments array must have arguments.” AppModule)

When running ng serve with a successful compilation in my Angular app, I started getting the following error in the browser console.

(当在Angular应用中运行ng serve并成功编译时,我开始在浏览器控制台中收到以下错误。)

AppComponent_Host.ngfactory.js? [sm]:1 ERROR Error: Arguments array must have arguments.

at injectArgs (core.js:1412)

at core.js:1491

at _callFactory (core.js:8438)

at _createProviderInstance (core.js:8396)

at resolveNgModuleDep (core.js:8371)

at NgModuleRef_.push../node_modules/@angular/core/fesm5/core.js.NgModuleRef_.get
(core.js:9064)

 at resolveDep (core.js:9429)

 at createClass (core.js:9309)

 at createDirectiveInstance (core.js:9186)

  at createViewNodes (core.js:10406)

This as far as I can tell from Main.ts platformBrowserDynamic().bootstrapModule(AppModule) .catch(err => console.log(err));

(据我从Main.ts platformBrowserDynamic().bootstrapModule(AppModule) .catch(err => console.log(err));得知,BrowserDynamic platformBrowserDynamic().bootstrapModule(AppModule) .catch(err => console.log(err));)

I have deleted the node modules folder and reinstalled and I'm having trouble with the lack of explanation the error gives.

(我已删除节点模块文件夹并重新安装,但由于错误给出的解释不足,我遇到了麻烦。)

Plus, I'm somewhat new to Angular.

(另外,我对Angular还是有些陌生。)

Any help would be greatly appreciated.

(任何帮助将不胜感激。)

EDIT(编辑)

I ran ng serve --aot and got the following error

(我ng serve --aot并出现以下错误)

ERROR in : Error: Internal error: unknown identifier []
 at Object.importExpr$$1 [as importExpr] (C:UserskgDocumentsang2adUI
[email protected]:21731:27)
 at C:UserskgDocumentsang2adUI
[email protected]:9988:37
 at Array.map (<anonymous>)
 at InjectableCompiler.depsArray (C:UserskgDocumentsang2adUI
[email protected]:9954:25)
 at InjectableCompiler.factoryFor (C:UserskgDocumentsang2adUI
[email protected]:10018:36)
 at InjectableCompiler.injectableDef (C:UserskgDocumentsang2adUI
[email protected]:10037:42)
 at InjectableCompiler.compile (C:UserskgDocumentsang2adUI
[email protected]:10047:106)
 at C:UserskgDocumentsang2adUI
[email protected]:21576:90
 at Array.forEach (<anonymous>)
 at AotCompiler._emitPartialModule2 (C:UserskgDocumentsang2adUI
[email protected]:21576:25)
 at C:UserskgDocumentsang2adUI
[email protected]:21569:48
 at Array.reduce (<anonymous>)
 at AotCompiler.emitAllPartialModules2 (C:UserskgDocumentsang2adUI
[email protected]:21568:26)
 at AngularCompilerProgram._emitRender2 (C:UserskgDocumentsang2adUI
[email protected]:364:31)
 at AngularCompilerProgram.emit (C:UserskgDocumentsang2adUI
[email protected]:236:22)
 at AngularCompilerPlugin._emit (C:UserskgDocumentsang2adUI
ode_modules@ngtoolswebpacksrcangular_compiler_plugin.js:846:49)

ngModule(ngModule)

@NgModule({
  declarations: [
    AppComponent,
    LoginComponent,
    ItemDashboardComponent,
    UnprotectedSearchComponent,
    HomeComponent,
    UnprotectedResultsComponent,
    DashboardComponent,
    TrackingListComponent,
    ListItemComponent,
    ActionItemComponent,
    ActionListComponent,
    ItemInfoTableComponent,
    TrackingInfoTableComponent,
    FilterPipe,
    RegisterItemsComponent,
    RegisterPackageComponent,
    AddItemsPackageComponent,
    ChangeCustodyComponent,
    CheckTempComponent,
    RemoveItemsComponent,
    ScannerComponent,
    ContainerDashboardComponent,
    SoldComponent
  ],
  imports: [
    NgQrScannerModule,
    MatTabsModule,
    AngularFontAwesomeModule,
    MatListModule,
    MatFormFieldModule,
    BrowserAnimationsModule,
    MatMenuModule,
    MatProgressBarModule,
    BrowserModule,
    MatIconModule,
    MatGridListModule,
    AngularFontAwesomeModule,
    FormsModule,
    AppRoutingModule,
    HttpClientModule,
    RouterModule.forRoot([
      {
        path: 'home',
        component: HomeComponent
      },
      //{path: 'openSearch', component: LoginComponent},
      {
        path: 'item',
        component: ItemDashboardComponent,
        canActivate: [AuthGuard, ManufacturerAuthGuardService]
      },
      {
        path: 'dashboard',
        component: DashboardComponent,
        canActivate: [AuthGuard]
      },
      {
        path: 'unprotectedResults',
        component: UnprotectedResultsComponent,
        canActivate: [AuthGuard]
      },
      {
        path: 'trackingList/'+environment.config.itemWorkflow+'/:contractId',
        component: ItemDashboardComponent,
        canActivate: [AuthGuard]
      },
      {
        path: 'trackingList/'+environment.config.packageWorkflow+'/:contractId',
        component: ContainerDashboardComponent,
        canActivate: [AuthGuard]
      },
      {
        path: 'trackingList',
        component: TrackingListComponent,
        canActivate: [AuthGuard]
      },
      {
        path: 'actions',
        component: ActionListComponent,
        canActivate: [AuthGuard]
      },
      {
        path: 'publicResults/:contractId',
        component: UnprotectedResultsComponent
      },
      {
        path: 'registerItems',
        component: RegisterItemsComponent,
        canActivate: [AuthGuard]
      },
      {
        path: 'addItemsToPackage',
        component: AddItemsPackageComponent,
        canActivate: [AuthGuard]
      },
      {
        path: 'registerPackage',
        component: RegisterPackageComponent,
        canActivate: [AuthGuard]
      },
      {
        path: 'changeCustody/:contractId',
        component: ChangeCustodyComponent,
        canActivate: [AuthGuard]
      },
      {
        path: 'changeCustody',
        component: ChangeCustodyComponent,
        canActivate: [AuthGuard]
      },
      {
        path: 'checkTemp',
        component: CheckTempComponent,
        canActivate: [AuthGuard]
      },
      {
        path: 'removeItems',
        component: RemoveItemsComponent,
        canActivate: [AuthGuard]
      },
      {
        path: 'sellItems',
        component: SoldComponent,
        canActivate: [AuthGuard]
      },


    ]),
    UiModule
  ],
  providers: [
    AuthGuard,
    {
      provide: HTTP_INTERCEPTORS,
      useClass: MyInterceptor,
      multi: true
    },
    MockBackend,
    fakeBackendProvider,
    BaseRequestOptions,
    AuthGuard,
    AdminAuthGuard,
    AdalService,
    SoldComponent
  ],
  bootstrap: [AppComponent]
})

AppComponent Constructor(AppComponent构造函数)

constructor(private api: ApiService, private adalService: AdalService, private _http: HttpClient, private router: Router, public authService: AuthService) {
    this.adalService.init(environment.config);
    if (!this.adalService.userInfo.authenticated) this.router.navigate(['/']);
  }
  ask by kg123 translate from so

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)

First, try building/serving the app with ng serve --aot flag.

(首先,尝试使用ng serve --aot标志构建/提供ng serve --aot 。)

Changes are some warning/error will be shown at the compile time.

(更改是一些警告/错误,将在编译时显示。)

As far as I can think, can you search in your project, if you are importing any component/module

(据我所知,如果要导入任何组件/模块,是否可以在项目中进行搜索)

like this import {something} from "../node_modules/@somepackage/adfas";

(像这样import {something} from "../node_modules/@somepackage/adfas";)

instead of import {something} from "@somepackage/adfas";

(而不是import {something} from "@somepackage/adfas";)


Also can you please share what you have in @NgModule({}) decorator, and in AppComponent constructor() ;

(您还可以分享@NgModule({})装饰器和AppComponent constructor()中的内容AppComponent constructor() ?)

I think the angular is not able to provide all the injected dependencies.

(我认为angular无法提供所有注入的依赖项。)


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...