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.

Angular5: StaticInjectorError // Solution: `--preserve-symlinks`

See original GitHub issue

Type of Issue

[x] Bug Report
[ ] Feature Request

Description

Several StaticInjectionError being reported.

How To Reproduce

Reproducible in the Angular CLI consumer in the integration tests:

$ cd integration/consumers/ng-cli
$ ng serve

(ng build in the CI tests work fine though!)

2017-11-29 11_44_56-consumerngcli

Expected Behaviour

needs investigation

Version Information

ng-packagr: next
node: v8.9.0
@angular: v5.0.1
typescript: 2.4.2

Issue Analytics

  • State:closed
  • Created 6 years ago
  • Reactions:1
  • Comments:14 (3 by maintainers)

github_iconTop GitHub Comments

2reactions
aryanismlcommented, Jan 25, 2018

Still facing the issue Uncaught (in promise): Error: StaticInjectorError Any solution on it.

Using Angular cli 1.5.4 and Angular 5.0.0 Created the service library which contained the httpclient.post() call and create the package using ng-packager. In consumer app added the service library package using npm.

On run time when we run the application it throw the error Uncaught (in promise): Error: StaticInjectorError No provider for httpclient

If we tested the service library code without consuming in any application it work as expected. when we consumed in any application and run that application it throw the run time error

Also try preserveSymlinks in angular.cli.json file in consumer application however no success still the error present run time. “defaults”: { “styleExt”: “css”, “build”: { “preserveSymlinks”: true }, “component”: {} } ***Service code application name - CommonApp

test.service.ts simply added the httpClient in constructor,

@Injectable() export class TestService {

constructor(private httpClient: HttpClient) { }
getData(){
    return 'Hello World';
}

}

The issue is resolved Updated angular cli and added “build”: { “preserveSymlinks”: true }, It’s working now.

1reaction
ronnyekcommented, Jan 22, 2018

I spoke too soon… looks like this is a preserveSymlinks thing helps, because I was testing the inclusion of my lib into a new dummy test app. This helps in debugging, but is this preserveSymlinks thing only a problem because of the npm link? (Should I be able to move forward and expcet my library to be installed into a new app from npm and just work?)

Read more comments on GitHub >

github_iconTop Results From Across the Web

Preserve Symlinks in Angular Libraries - Stack Overflow
I'm trying to make a Angular 8 Library using ng-cli, but i can't preserve symlinks from my external application using npm link ....
Read more >
[Solved]-Angular testing with primeng : NullInjectorError ...
Coding example for the question Angular testing with primeng ... Accepted answer. SOLVED. My angular.json's test section (added "preserveSymlinks": true):
Read more >
Angular library integration of devExtrme controls
when I use this shared library in other angular application I am getting static injection error. JavaScript. Error: StaticInjectorError( ...
Read more >
Angular6: No Provider for Injector when using local library – iTecNote
I'm somewhat new to Angular versions post AngularJS and decided to give them a try. ... Error: StaticInjectorError(AppModule)[MyButtonModule -> Injector]: ...
Read more >
How to Create & Publish an Angular Library with Ionic ...
Since a later version the Angular CLI allows to create a workspace ... Ionic project and add the preserveSymlinks entry at the shown...
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