-
Notifications
You must be signed in to change notification settings - Fork 24.8k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Uncaught Error: Can't resolve all parameters for ... #19417
Comments
Just in case you need to see how looks my app.component.ts
|
You are missing an |
@benelliott Thank you for the hint. I'm sorry but I thought it was an issue in angular. I've done a lot of research on StackOverflow and on Internet in general, but didn't find a solution.,..So I thought it was an angular issue...Closing it. Thank you and sorry again |
Error: Can't resolve all parameters for Router: (?, ?, ?, ?, ?, ?, ?, ?). I have this error in my angular4 app testing |
I faced the same issue and resolved |
I was missing the @ in front of Injectable(). |
After 1 day on this I realized I had removed some polyfills I didn't think I need.
|
Another scenario for this problem to appear seems to be if you have "ng build --watch" running, and then do "ng build --prod=env" this will cause the DIST files built to be corrupt, and with errors, for my instance it was an error in my data service regarding the @Injectable. So might want to stop the "ng build --watch" then once it's fully stopped, run "ng build --prod=env". Just an FYI for those who ran into this issue. |
After strugling for 1 hour on this, finally, thanks to @odolha , it appears I also had removed core-js/es7/reflect. |
Any thoughts on adding actual useful error messages that detect common Angular pitfalls like Vue does? |
I had this error message also ... what resolved it for me was importing Services from the same Module with relative paths rather than using a barrel. |
@kabb5 That's not something can be helped by Angular, what Angular can get is only an |
I got this error when upgrading an app from angular2 to angular5. In addition to upgrading the CLI and the dependencies and devDependencies in the rm -rf node_modules/
npm i |
@odolha this was my issue as well. Glad you spent the day and not me (only took about 20 min to find your post) The reason I had removed the polyfill was because there is a comment in the So, I was doing some optimizing for my aot deployment and got rid of it... completely forgetting that local development (using ng-serve) is still using JIT :( So, thank you sir... |
The 'core-js/es7/reflect' polyfill is necessary since JIT compilation is used during tests. I found the solution in the discussion here: angular/angular#19417 (comment)
Even I faced this issue for a service. For me, adding back ES7/reflect polyfill in polyfill.ts resolved the issue. I had removed them by error. |
For the record, I've just lost a full day on this error... 😭 In
is your first line. |
Okay , so I have finally decoded the error . |
can occur also with circular dependencies (exported helper structures between files). |
thank you all, i had the same problem: i had removed the core-js/es7/reflect after adding it worked again :) |
I finally found out what was wrong in my case as well. It looks like it is actually telling me that the place where the question mark is, has an issue. In my case I had HttpClient and a string in the url. In the hope to eventually use it within a provider and provide that string. but it looks like this not not allowed any more? My service was:
Using inside a module like so:
It did work though..yet it does give me a warning now that it will be an error in a later version... |
i had import core-js/es7/reflect in polyfill.ts but i still have this error. its confuse me a lot.
|
@dongdongmao i had this issue many times when: |
@SerkanSipahi actually i useing |
and if i use |
This can also happen when your component extends another one and you forgot to call the |
This was the case for me, extended a class and did not define the |
Happened to me with providing faulty data through the constructor. |
The same error occurred to me and I could solve it by rearranging the app.module.ts so that the dependencies are in order of how they are imported. One service imported another that was defined below in the app.module.ts and apparently that was the problem. It was magically solved! |
We run Angular 2 in a custom Webpack config, without the CLI. After a careful upgrade to Babel 7, we discovered this issue and it got us stumped. A few days later, and the problem is fixed by importing a polyfill 😄 |
I think the error message should try be more specific on unresolved parameter |
I got this as well today, as I forgot to add constructors for a derived class. Was happy with AOT, but not compiling on the fly. I would have expected the AOT compiler to catch this. |
if you have an index.ts to export your services, check the order of exports. that helped me. |
I'm getting this error in the browsers console: "Can't resolve all parameters for OrdineComponent: (?)." Can anyone help me? I have everything on this repository |
Its clear that you are trying to inject the ordine service in the ordine component and ordine component in service. That is not possible. to instantiate the component you need the service and to instantiate the service you need the component. Please read about the dependency injection pattern. |
I have run into this trying to inject an interface, thinking it was a class -> make sure your component level variables are declared outside of your constructor injection. |
In my case this problem appear only with and it was in the following code:
maybe it helps some one |
It seems this message can have many causes. In my case, it was because I tried to inject service classes from a library, except these classes don't have an |
In my case I was simply injecting in the constructor the Router service without using it. After deleting this, everything works fine. |
Hahaha.I also encountered this situation. |
This error might also occur when you have circular dependencies (for example because you use barrel imports in a wrong way). This might be especially confusing because the dependency injection will work in other classes but not in the one that has a circular dependency. |
Problem was solved by adding Inject directive to Service in Component |
I had a slightly different problem so I'll drop it here in case anyone else runs across it. I had recently spun up an v8 project, and ran into the high memory issues when compiling for prod angular/angular-cli#13734. Could not figure out a solution I was happy with so reverted back to v7. The projects generated for v8 have a different transpile targets in the tsconfig and therefore the decoration of modules is different. Anyway in my case I needed to use the targets/modules values from a V7 project. TL;DR: If you reverted from an NG8 project back to NG7. Use this NG7 tsconfig.json:
|
In my case the problem has already occurred when a component file exports more than one object type for example: 'my-test.component.ts export enum MyTestEnum { @component (...) |
This issue has been automatically locked due to inactivity. Read more about our automatic conversation locking policy. This action has been performed automatically by a bot. |
I'm submitting a...
Current behavior
Getting an error in the browser console: "Uncaught Error: Can't resolve all parameters for ApiService "
Note: ApiService is, I guess, the name of my Service.
Expected behavior
Should inject HttpClient in my service, in developement mode and production mode
Minimal reproduction of the problem with instructions
Hi Guys..I've done a small angular-cli project. I've created 3 services that will get datas. One service is called "FakeService", because it will provide harcoded data...The other service is called "TestService", which has another service (ApiService) injected in its constructor. The ApiService will use HttpClient to get datas from server.
But I got the described error message when I'm using the FakeService (in developement mode)
Here is my app.module.ts
Here is my api.service.ts
Here is my fake.service.ts
And Finally, here is my test.service.ts
As you can see in test.service.ts, I inject my other ApiService in the constructor.
As you can see in app.module.ts, I'm using TestService when I'm in production (for example, when calling
ng serve --prod
) and I'm using FakeService when not in production (ng serve
)I have no error message when calling
ng serve --prod
. But I have the following error message when serving in development mode, aka when using FakeService instead of TestService (ng serve
)If I remove the constructor's parameter (private httpClient: HttpClient) in my ApiService, I have no error issue when running in developement mode (so when it uses FakeService) but I can't use httpClient to make Http requests.. I've followed the instructions as described in Angular HttpClient doc for the use of HttpClient.
I don't know If it's a true angular issue or if I've done something wrong.. Could you please help me with this issue ?
Thank you very much for your help.
Environment
The text was updated successfully, but these errors were encountered: