'Angular 12 - The target entry-point has missing dependencies
I have an external library and I started to integrate with Azure Application Insights. I followed this tutorial https://devblogs.microsoft.com/premier-developer/angular-how-to-add-application-insights-to-an-angular-spa/ here and now I am getting this error below:
[karma-server]: Error: The target entry-point "mylib" has missing dependencies:
- @microsoft/applicationinsights-web
My appplication-insights-service.ts
import { ApplicationInsights } from '@microsoft/applicationinsights-web';
@Injectable()
export class MyMonitoringService {
appInsights: ApplicationInsights;
constructor() {
this.appInsights = new ApplicationInsights({
config: {
instrumentationKey: environment.instrumentationKey,
enableAutoRouteTracking: true // option to log all route changes
}
});
this.appInsights.loadAppInsights();
}
logPageView(name?: string, url?: string) { // option to call manually
this.appInsights.trackPageView({
name: name,
uri: url
});
}
logEvent(name: string, properties?: { [key: string]: any }) {
this.appInsights.trackEvent({ name: name}, properties);
}
logMetric(name: string, average: number, properties?: { [key: string]: any }) {
this.appInsights.trackMetric({ name: name, average: average }, properties);
}
logException(exception: Error, severityLevel?: number) {
this.appInsights.trackException({ exception: exception, severityLevel: severityLevel });
}
logTrace(message: string, properties?: { [key: string]: any }) {
this.appInsights.trackTrace({ message: message}, properties);
}
Package.json
"peerDependencies": {
"@angular/common": ">=12.0.0",
"@angular/core": ">=12.0.0",
"@angular/http": ">=12.0.0",
"angular-oauth2-oidc-jwks": "^12.0.0",
"angular-oauth2-oidc": "^12.0.0",
"jwt-decode": "^2.2.0",
"@microsoft/applicationinsights-web": "^2.7.3"
},
myLib-commons-module.ts
@NgModule({
imports: [HttpClientModule, OAuthModule],
providers: [
{ provide: ErrorHandler, useClass: ErrorHandlerService }
],
})
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
Solution | Source |
---|