«Ошибка: массив аргументов должен иметь аргументы.»AppModule - PullRequest
0 голосов
/ 11 октября 2018

При запуске ng serve с успешной компиляцией в моем приложении Angular я начал получать следующую ошибку в консоли браузера.

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)

Это, насколько я могу судить из Main.ts platformBrowserDynamic().bootstrapModule(AppModule) .catch(err => console.log(err));

Я удалил папку узловых модулей и переустановил, и у меня возникли проблемы с отсутствием объясненияошибка дает.Кроме того, я немного новичок в Angular.

Любая помощь будет принята с благодарностью.

РЕДАКТИРОВАТЬ

Я запустил ng serve --aot и получил следующую ошибку

ERROR in : Error: Internal error: unknown identifier []
 at Object.importExpr$$1 [as importExpr] (C:\Users\kg\Documents\ang2\ad\UI\node_modules\@angular\compiler\bundles\compiler.umd.js:21731:27)
 at C:\Users\kg\Documents\ang2\ad\UI\node_modules\@angular\compiler\bundles\compiler.umd.js:9988:37
 at Array.map (<anonymous>)
 at InjectableCompiler.depsArray (C:\Users\kg\Documents\ang2\ad\UI\node_modules\@angular\compiler\bundles\compiler.umd.js:9954:25)
 at InjectableCompiler.factoryFor (C:\Users\kg\Documents\ang2\ad\UI\node_modules\@angular\compiler\bundles\compiler.umd.js:10018:36)
 at InjectableCompiler.injectableDef (C:\Users\kg\Documents\ang2\ad\UI\node_modules\@angular\compiler\bundles\compiler.umd.js:10037:42)
 at InjectableCompiler.compile (C:\Users\kg\Documents\ang2\ad\UI\node_modules\@angular\compiler\bundles\compiler.umd.js:10047:106)
 at C:\Users\kg\Documents\ang2\ad\UI\node_modules\@angular\compiler\bundles\compiler.umd.js:21576:90
 at Array.forEach (<anonymous>)
 at AotCompiler._emitPartialModule2 (C:\Users\kg\Documents\ang2\ad\UI\node_modules\@angular\compiler\bundles\compiler.umd.js:21576:25)
 at C:\Users\kg\Documents\ang2\ad\UI\node_modules\@angular\compiler\bundles\compiler.umd.js:21569:48
 at Array.reduce (<anonymous>)
 at AotCompiler.emitAllPartialModules2 (C:\Users\kg\Documents\ang2\ad\UI\node_modules\@angular\compiler\bundles\compiler.umd.js:21568:26)
 at AngularCompilerProgram._emitRender2 (C:\Users\kg\Documents\ang2\ad\UI\node_modules\@angular\compiler-cli\src\transformers\program.js:364:31)
 at AngularCompilerProgram.emit (C:\Users\kg\Documents\ang2\ad\UI\node_modules\@angular\compiler-cli\src\transformers\program.js:236:22)
 at AngularCompilerPlugin._emit (C:\Users\kg\Documents\ang2\ad\UI\node_modules\@ngtools\webpack\src\angular_compiler_plugin.js:846:49)

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(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(['/']);
  }

Ответы [ 4 ]

0 голосов
/ 29 июля 2019

У меня была такая же проблема, просто попытался запустить приложение снова, и оно заработало.

0 голосов
/ 16 июня 2019

В моем случае я пропустил введенный тип в конструкторе: /

0 голосов
/ 01 июля 2019

Этот фрагмент Typescript демонстрирует сценарий, который вызывает эту ошибку.

...

export class AClassImportingAService {

    constructor(private _importedService) {
        // ERROR: notice there is no type on _importedService
        //   It should read 'private _importedService: ImportedService'
    }

...
}
0 голосов
/ 11 октября 2018

Сначала попробуйте собрать / обслуживать приложение с флагом ng serve --aot.Изменения - некоторые предупреждения / ошибки будут отображаться во время компиляции.

Насколько я могу судить, можете ли вы выполнить поиск в своем проекте, если вы импортируете какой-либо компонент / модуль

, как этотimport {something} from "../node_modules/@somepackage/adfas"; вместо import {something} from "@somepackage/adfas";


Также не могли бы вы поделиться тем, что у вас есть в @NgModule({}) декораторе и в AppComponent constructor();

Я думаю, что угловой не можетпредоставить все введенные зависимости.

Добро пожаловать на сайт PullRequest, где вы можете задавать вопросы и получать ответы от других членов сообщества.
...