question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

"Cannot resolve all parameters" with AOT

See original GitHub issue

I’m submitting a…


[ ] Regression (a behavior that used to work and stopped working in a new release)
[X] Bug report  
[ ] Performance issue
[ ] Feature request
[ ] Documentation issue or request
[ ] Support request => Please do not submit support request here, instead see https://github.com/angular/angular/blob/master/CONTRIBUTING.md#question
[ ] Other... Please describe:

According to my researches this issue is not the same as existing ones even if the error message is the same (#22532, #22244 …)

Current behavior

When project is run with ng serve --aot I have the following error in the browser :

09:32:05.275 main.ts:9 pre-test
09:32:05.277 test.1.ts:46 step 1
09:32:05.278 core.js:1926 Uncaught Error: Cannot resolve all parameters for 'CustomProvider'(?). Make sure that all the parameters are decorated with Inject or have valid type annotations and that 'CustomProvider' is decorated with Injectable.
    at noAnnotationError (core.js:1926)
    at _dependenciesFor (core.js:2256)
    at resolveReflectiveFactory (core.js:2157)
    at resolveReflectiveProvider (core.js:2180)
    at Array.map (<anonymous>)
    at resolveReflectiveProviders (core.js:2187)
    at Function.push../node_modules/@angular/core/fesm5/core.js.ReflectiveInjector.resolve (core.js:2384)
    at Function.push../node_modules/@angular/core/fesm5/core.js.ReflectiveInjector.resolveAndCreate (core.js:2410)
    at test (test.1.ts:47)
    at Module../src/main.ts (main.ts:10)
noAnnotationError @ core.js:1926
_dependenciesFor @ core.js:2256
resolveReflectiveFactory @ core.js:2157
resolveReflectiveProvider @ core.js:2180
resolveReflectiveProviders @ core.js:2187
push../node_modules/@angular/core/fesm5/core.js.ReflectiveInjector.resolve @ core.js:2384
push../node_modules/@angular/core/fesm5/core.js.ReflectiveInjector.resolveAndCreate @ core.js:2410
test @ test.1.ts:47
./src/main.ts @ main.ts:10
__webpack_require__ @ bootstrap:78
0 @ test2.ts:15
__webpack_require__ @ bootstrap:78
checkDeferredModules @ bootstrap:45
webpackJsonpCallback @ bootstrap:32
(anonymous) @ main.js:1

Expected behavior

I should have the same output I have in JIT

09:40:34.742 main.ts:9 pre-test
09:40:34.743 test.1.ts:46 step 1
09:40:34.745 test.1.ts:53 step 2
09:40:34.746 test.1.ts:10 LocalBaseClass _injector ReflectiveInjector_ {_constructionCounter: 1, _providers: Array(4), parent: null, keyIds: Array(4), objs: Array(4)}
09:40:34.748 test.1.ts:11 LocalBaseClass this._injector ReflectiveInjector_ {_constructionCounter: 1, _providers: Array(4), parent: null, keyIds: Array(4), objs: Array(4)}
09:40:34.749 test.1.ts:55 step 3
09:40:34.749 test2.ts:11 ExternalBaseClass _injector ReflectiveInjector_ {_constructionCounter: 3, _providers: Array(4), parent: null, keyIds: Array(4), objs: Array(4)}
09:40:34.750 test2.ts:12 ExternalBaseClass this._injector ReflectiveInjector_ {_constructionCounter: 3, _providers: Array(4), parent: null, keyIds: Array(4), objs: Array(4)}
09:40:34.751 test.1.ts:57 step 4
09:40:34.751 main.ts:11 post-test
09:40:34.846 core.js:3123 Angular is running in the development mode. Call enableProdMode() to enable the production mode.

Minimal reproduction of the problem with instructions

I have attached a demo project. In order to create this project I used ng cli to bootstrap the project, then added files test.1.ts and test.2.ts. And an simple call to test() function from main.ts

test3.zip

What is the motivation / use case for changing the behavior?

Environment


Angular version: ^6.1.0


Browser:
- [X] Chrome (desktop) version 68.0.3440.106
- [ ] Chrome (Android) version ^6.1.0
- [ ] Chrome (iOS) version XX
- [ ] Firefox version XX
- [ ] Safari (desktop) version XX
- [ ] Safari (iOS) version XX
- [ ] IE version XX
- [ ] Edge version XX
 
For Tooling issues:
- Node version: v8.9.4  
- Platform:  Windows 10

 

Others:

Issue Analytics

  • State:closed
  • Created 5 years ago
  • Comments:7 (3 by maintainers)

github_iconTop GitHub Comments

1reaction
mlc-mlapiscommented, Sep 19, 2018

@no-more … nobody will download a foreign ZIP file. So still create that Plunker demo even if the error wouldn’t be seen, because of the source code shows the mistake. From 99,9% it’s your mistake.

1reaction
no-morecommented, Sep 19, 2018

Thanks but I don’t know how to create a plunker with AOT. Plunker is great tool for code issue, here I think the issue might be related to the compiler (ngc + aot in this case).

Read more comments on GitHub >

github_iconTop Results From Across the Web

Angular cli 2 Error Can't resolve all parameters for XXXXX by ...
Hi, there are a lot of reason for this problem. Start by taking a look here github.com/angular/angular-cli/issues/4551 and then check your ...
Read more >
Optional triggers warning "Can't resolve all parameters" with ...
The AOT compiler is going to create an extra file imports the token, but a non-export class cannot be referenced, which cause the...
Read more >
[Solved]-AOT Can't resolve all parameters for [...]-angular.js
I encountered this error when building a parent angular project with AOT enabled that had a child angular library project I had packaged...
Read more >
Fixing the "can't resolve all parameters" exception with ...
Yesterday, I've stumbled on a puzzling issue while implementing a new service in the application.
Read more >
Can't resolve all parameters for MyApp - Ionic Forum
[UPDATE] problem solved, it was a faulty parameters in the constructor, removed, solved. Hello, am getting this error, and i cant seem to...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found