Having trouble resolving all parameters for the component xyz: (?, ?) after the upgrade to Angular 2 CLI

After upgrading my Angular2 project from Beta .21 to beta .25.5, which was functioning smoothly, I resolved all errors for both AOT and non-AOT (e.g. ng serve) functionalities.

However, upon browser loading, I encountered an error affecting multiple services at runtime, displaying:

Can't resolve all parameters for *servicename*: (?)     

Initially, I eliminated circular dependencies and removed the barrel I was utilizing. Subsequently, I relocated all services to the Providers array in App.module and verified the presence of @Injectable() in all services.

The sole solution to eliminate the error was employing the Inject() method, like so:

import { Injectable, Optional, SkipSelf, Inject } from '@angular/core';
import { Subject } from 'rxjs/Subject';

export interface SpinnerState {
    show: boolean;
}

@Injectable()
export class SpinnerService {
    private spinnerSubject = new Subject<SpinnerState>();

    spinnerState = this.spinnerSubject.asObservable();

    constructor( @Optional() @SkipSelf() @Inject(SpinnerService) prior: SpinnerService) {

Although this step fixed the initial errors, a subsequent error surfaced regarding a 3rd party library. How can I effectively troubleshoot to pinpoint the root cause?

Regards

"

nativeError : Error: Can't resolve all parameters for Logger: (?). at SyntaxError.BaseError [as constructor] (http://localhost:4200/vendor.bundle.js:134335:27) [<r
"

This represents the structure of my App.Module:

 providers: [
        {
            provide: AuthHttp,
            useFactory: authHttpServiceFactory,
            deps: [Http, RequestOptions],
        },
        [Logger],
        LoggerService,
        SpinnerService,
        DataBreezeService,
        ProfileService,
        AuthService,
        AuthGuardService,
        CanDeactivateGuardService,

Additionally, the following configurations are also in place:

{
  "emitDecoratorMetadata": true,
  "experimentalDecorators": true
}

(It's worth mentioning that my project was fully operational before the upgrade, with no apparent issues noted in the release notes).

UPDATE As I continued troubleshooting by commenting out problematic services and eliminating constructor parameters, the error persisted in moving to the next service - indicating a higher-level issue. Furthermore, I started encountering 404 errors on components, for example:

https://i.sstatic.net/SOwiA.png

Despite numerous attempts to rectify the situation, including the addition of "moduleId: 'module.id', ", the 404 error on the Subscribe component remained:

import { Component } from '@angular/core';

@Component({
    selector: 'app-subscribe',
    templateUrl: './subscribe.component.html',
    styleUrls: ['./subscribe.component.scss']
})
export class SubscribeComponent {

    constructor() { }
}

GET http://localhost:4200/subscribe.component.html 404 (Not Found)

Answer №1

Managed to get it running smoothly by eliminating all barrel imports and upgrading to beta version 28.3

npm uninstall -g angular-cli
npm cache clean
npm install -g <a href="/cdn-cgi/l/email-protection" class="__cf_email__" data-cfemail="2b4a454c5e474a59064847426b1a051b051b06494e5f4a0519130518">[email protected]</a>

Additionally, make sure to update to version 28.3 within the project folder (update angular-cli.json & package.json).

Similar questions

If you have not found the answer to your question or you are interested in this topic, then look at other similar questions below or use the search

The table on the page shifts position when viewed on different devices, sometimes not remaining between the header and footer

Here is a link to see how my page looks with the header, table, and footer: https://i.sstatic.net/U6tdO.png If you want to see how it looks when responsive (with smaller width), check out this link: https://i.sstatic.net/zsGkc.png I have encountered 2 ma ...

The issue of losing context when using Papaparse with an Angular 4 function

Check out this block of code httpcsv2Array(event) { var gethttpcsv = Papa.parse('https://docs.google.com/spreadsheets/d/e/yadyada/pub?output=csv', { download: true, header: true, ...

Is there a way to update the parent state from a child component in React when using Switch Route?

I have a page that features a control panel for modifying the content on display through Switch-Route. The code structure is as follows: <div className="controls"> some controls here </div> <Switch> <Route exact path=&apo ...

Destructuring objects with default values from two related interfaces

In my project, I have defined two interfaces called User and BankUser. The structure of the interface for BankUser looks like this: interface BankUser extends User { banks: { [bank_id: string]: string}; isSuper: boolean; } I am working on a function ...

The real file that was brought in after indicating a module in the node_modules directory that was coded in Typescript

After creating a typescript module named moduleA, I am ready to publish this package and make it accessible from another typescript project. Currently, for testing purposes, I have installed 'moduleA' using 'npm install ../moduleA'. Th ...

Angular: finding out if Observable or BehaviorSubject has undergone any important modifications

I am facing an issue with my user object in a membership service. I need to ensure that my services are updated only when there are relevant changes in the user object. To determine if there are relevant changes in the user object, I compare it with the ...

Trouble triggering hidden radio button in Angular 9 when clicked

I have implemented radio buttons within a div with the following CSS styles (to enable selection by clicking on the div): .plans-list { display: flex; justify-content: center; margin: 2rem 0; .plan { display: flex; margin: 0 0.5rem; p ...

Leveraging Angular2 for Azure AD authentication

Currently working with Angular2 and looking to authenticate users through Azure AD. I came across ADALjs, but it's specifically for Angular1. I also found this https://www.npmjs.com/package/angular2-adal#adalService, however it appears to still be in ...

Create an array form with the first input at index 0 filled out

Currently, I am in the process of developing a form that allows users to update, add, delete, and edit entries using Angular 2 and reactive forms. To achieve this, I have utilized a form builder array to dynamically add input controls to the form array. Ev ...

Encountering difficulties with Bootstrap toggle functionality in Angular 2.0 following the establishment of a MEAN stack

While setting up a MEAN stack app following a tutorial, everything was going smoothly until I decided to test some Bootstrap components from their site. After installing Bootstrap in the index.html file for Angular, I noticed that Bootstrap was being loade ...

The function ValueChange remains uninvoked

Query: The issue is that valueChanges is only triggered for the entire form and not for specific controllers. Although this approach works, it returns the complete object. public ngOnInit(): void { this.form.createWagonBodyForm(); ...

Using React to map and filter nested arrays while also removing duplicates

Hello, I recently started working with react and I've encountered a challenge while trying to map an array. const fullMen = LocationMenuStore.menuItems['menu']['headings'].map((headings: any) => { <Typography>{ ...

Filter through the array of objects using the title key

I'm attempting to extract specific data by filtering the 'page_title' key. Below is a snippet of my JSON object: { "page_components": [ { "page_title": "My Account", "row_block": [ { "heading": "", "sub_headi ...

What is the functionality of angular's @Attribute decorator?

Just starting out with Angular and diving into the world of decorators. While exploring the angular.io documentation, I found limited information on the @Attribute decorator. Can anyone provide me with some practical use cases for this? ...

Getting parameters from the URL in Angular 2: A step-by-step guide

I attempted to accomplish this in the ngOnInit() function as shown below: ngOnInit() { this.route.queryParams .filter(params => params.type) .subscribe(params => { this.tab = params.type; this.setHeader(); }); ...

Adding a tooltip to an Angular Material stepper step is a great way to provide

I am trying to implement tooltips on hover for each step in a stepper component. However, I have encountered an issue where the matTooltip directive does not seem to work with the mat-step element. <mat-horizontal-stepper #stepper> <mat-step lab ...

Find the identifier that does not currently exist in the collection of objects

There is a situation where I have an array and an object that consists of arrays of ids, which are essentially permission objects. My goal now is to extract the ids that do not exist in the given object. Can someone assist me with devising the necessary l ...

What are some key indicators in the source code that differentiate TypeScript from JavaScript?

Reviewing some code on Github, I am looking for ways to quickly determine whether the script is written in JavaScript or TypeScript. Are there any simple tips or hints that can help with this? For instance, when examining an array declaration like the on ...

What is the best way to allocate string types from an enum using Typescript?

Within my code, I have an enum that includes a collection of strings export enum apiErrors { INVALID_SHAPE = "INVALID_SHAPE", NOT_FOUND = "NOT_FOUND", EXISTS = "EXISTS", INVALID_AUTH = "INVALID_AUTH", INTERNAL_SERVER_ERROR = "INTERNAL_ ...

Having trouble getting anime.js to function properly in an Ionic 3 project?

I have been attempting to incorporate anime.js into my Ionic 3 project, but I keep encountering an error when using the function anime({}) in the .ts file. Error: Uncaught (in promise): TypeError: __webpack_require__.i(...) is not a function TypeError: _ ...