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
StaticInjectionError for service after migrating to Angular 5. // Solution: --preserve-symlinks
#299
Comments
I've got the same issue in my project. |
It turns out the problem is from another component module in my project. The module MyNavbarModule has a dependency on MyTestService. I have to add MyTestService to MyNavbarModule's providiers in addition to add it in the AppModule's providers. Then the error will go away. But I don't think it is correct since there will have two instances of the MyTestService in my application. Right? When I test MyNavbarModule independently, I don't need to add MyTestService to MyNavbarModule's providers. Only when I package the module as NPM package and to use it in another project I need to do this. Also when using Angular 4.2.4, I DO NOT need to do it. |
For Angular v5, please use the 2.0.0 release candidates! Make sure you have a typescript version that is supported by Angular, i.e. "~2.4.x" for angular v5. Should the error still exist, please provide a reproduction, e.g. a GitHub repo. For Angular v4, please use the 1.x version as it has the peerDependency on TypeScript 2.3.x which is recommended/supporter for Angular 4. |
hi @dherges, Thank you for your hint. I tried the latest rc and I still have the same issue :
I will try to create a github repo with reproduction of the issue. |
I’m pretty sure I know what’s wrong, but I’d like that reproduction repo before I say anything (just to be sure). |
@dherges I have the same problem with v2.0.0-rc.3. You can try it on this branch https://github.com/videogular/videogular2/tree/migration/angular5 Build first Core and then Controls. It works on compilation time but on execution time it throws this error:
BTW, this tool is amazing, thank you for the great job! 👍 |
Hi @Elecash, thank you! good! VgFullscreenAPI = __decorate$4([
Injectable(),
__metadata$2("design:paramtypes", [])
], VgFullscreenAPI); Compared to a working example: IconRegistry = __decorate$15([
Injectable(),
__metadata$9("design:paramtypes", [HttpClient])
], IconRegistry); The Why is the The VgPlayer = __decorate$1$1([
Component({
selector: 'vg-player',
encapsulation: ViewEncapsulation.None,
template: "\n <ng-content></ng-content>\n ",
styles: ["\n vg-player {\n font-family: 'videogular';\n position: relative;\n display: flex;\n width: 100%;\n height: 100%;\n overflow: hidden;\n background-color: black; }\n vg-player.fullscreen {\n position: fixed;\n left: 0;\n top: 0; }\n vg-player.native-fullscreen.controls-hidden {\n cursor: none; }\n "],
providers: [VgAPI, VgFullscreenAPI, VgControlsHidden]
}),
__metadata$1$1("design:paramtypes", [ElementRef, VgAPI, VgFullscreenAPI, VgControlsHidden])
], VgPlayer); ... and exposed as provider in
compared to the working example where the difference is that the provider is declared in a
|
This is different to the examples I have, where those services are exposed in the export { /* .. */ IconRegistry, IconComponent, IconModule,/* .. */ }; |
@dherges yes, I have to do some changes I will review your suggestions but I think that I can make it work. Thank you! |
Hi @Elecash, let's see if we can find iut the cause for the StaticInjection error message. The only difference I see is that the service is not explicitly exported in Checked then the AoT {"__symbolic":"reference","module":"@videogular/core","name":"VgFullscreenAPI"} So that should be good to look up the injectable from |
Any progress on this? I have a lib working on an angular 5 project that's been ejected from the angular/cli, but am still running into StaticINjectionError[Router] on a separate project that is using the angular/cli. EDIT: After doing the following steps, the library started working in the Angular CLI consumer app
|
See #335 (comment) : |
Still facing the issue Uncaught (in promise): Error: StaticInjectorError Any solution on it. Using Angular cli 1.5.4 and Angular 5.0.0 On run time when we run the application it throw the error If we tested the service library code without consuming in any application it work as expected. Also try preserveSymlinks in angular.cli.json file in consumer application however no success still the error present run time. test.service.ts simply added the httpClient in constructor, @Injectable()
} The issue is resolved Updated angular cli and added |
--preserve-symlinks
Why is this closed? It seems it is not fixed, or is it? |
Above solution works, but I assume it's workaround. |
I've set preserveSymlinks and I'm running into this with
My ng-packagr run looks like this:
When I start up ng serv -watch:
And in browser:
|
@dherges should this really be closed? |
I had the same issue and I've spent a full day trying to fix it. Deleting the |
LOL I went through the comments actually no damn one gave a particular solution, man just put your service class in your app.moudule.ts' providers array , you forgot that only , happy coding ❤️ |
This issue has been automatically locked due to inactivity. |
Type of Issue
Service package error after migrate to Angular 5
[x] Bug Report
[ ] Feature Request
ng-packagr: v1.6.0
node: v8.x.y
@angular: v5.0.0
rxjs:
zone.js:
The text was updated successfully, but these errors were encountered: