Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

1.7K
Views
Angular: 12 - No se puede acceder a 'AppComponent' antes de la inicialización al hacer "prueba ng"

Cuando intento ejecutar "prueba ng", obtengo lo siguiente:

Mensaje de error en la interfaz de usuario de Karma v 6.3.4 :
0 especificaciones, 0 fallas, aleatorizado con semilla 98146 Error durante la carga: error de referencia no capturado: no se puede acceder a 'AppComponent' antes de la inicialización en http://localhost:9876/karma_webpack/main.js línea 125

Mensaje de error en la terminal :
Se arrojó un error en afterAll Uncaught . .36747 (http://localhost:9876/ karma_webpack /webpack:/src/app/ app.module.ts:16:5 )

ARCHIVO TS del módulo de aplicación :

 import { NgModule } from '@angular/core'; import { AppRoutingModule } from './app-routing.module'; import { AppComponent } from './app.component'; import { ServiceWorkerModule } from '@angular/service-worker'; import { environment } from '../environments/environment'; import { BrowserAnimationsModule } from '@angular/platform-browser/animations'; import { NgxUiLoaderModule } from 'ngx-ui-loader'; import { MatSnackBarModule } from '@angular/material/snack-bar'; import { HttpClientModule, HTTP_INTERCEPTORS } from '@angular/common/http'; import { HttpConfigInterceptor } from './auth/httpconfig.interceptor'; import { HeaderModule } from './shared/header/header.module'; import { RouterModule } from '@angular/router'; @NgModule({ declarations: [ AppComponent ], imports: [ AppRoutingModule, BrowserAnimationsModule, ServiceWorkerModule.register('ngsw-worker.js', { enabled: environment.serviceWorker, registrationStrategy: 'registerImmediately' }), NgxUiLoaderModule, MatSnackBarModule, HttpClientModule, HeaderModule ], providers: [ AppComponent, { provide: HTTP_INTERCEPTORS, useClass: HttpConfigInterceptor, multi: true } ], exports: [ RouterModule ], bootstrap: [AppComponent] }) export class AppModule { }

¿Alguien sabe cómo podemos solucionar esto?

over 4 years ago · Santiago Trujillo
2 answers
Answer question

0

Debe intentar eliminar AppComponent de la matriz de providers . Eso puede causar el error que está encontrando.

over 4 years ago · Santiago Trujillo Report

0

Cuando intento ejecutar "prueba ng", obtengo lo siguiente:

Tiene un archivo de prueba que termina en "spec.ts" que está mal configurado y que está causando este error. Verifique las opciones del desarrollador del navegador y descubra que la intromisión *spec.ts . Después de eso tienes dos opciones:

  • elimine ese archivo de prueba si no planea probar o
  • agregue los modules requeridos, providers , ... en su TestBed.configureTestingModule(...) , para que el archivo spec.ts pueda compilarse correctamente.
over 4 years ago · Santiago Trujillo Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!