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.

StaticInjectionError for service after migrating to Angular 5. // Solution: `--preserve-symlinks`

See original GitHub issue

Type of Issue

Service package error after migrate to Angular 5

[x] Bug Report [ ] Feature Request


## Description

I have an Angular CLI generated project that just has only one service file my-test.service.ts

@Injectable()
export class MyTestService {
   ......
}

I publish it to NPM using ng-packagr. I can use the package in my other projects before migrating to Angular 5. After migration, I got error:
 
ERROR Error: StaticInjectorError[MyTestService]: 
  StaticInjectorError[MyTestService]: 
    NullInjectorError: No provider for MyTestService!
    at _NullInjector.get (core.js:923)
    at resolveToken (core.js:1211)
    at tryResolveToken (core.js:1153)
    at StaticInjector.get (core.js:1024)
    at resolveToken (core.js:1211)
    at tryResolveToken (core.js:1153)
    at StaticInjector.get (core.js:1024)
    at resolveNgModuleDep (core.js:10585)
    at NgModuleRef_.get (core.js:11806)
    at resolveDep (core.js:12302)

#### How To Reproduce



#### Expected Behaviour



#### Version Information

ng-packagr: v1.6.0 node: v8.x.y @angular: v5.0.0 rxjs: zone.js:


_please include any version information that might be relevant, e.g. other third-party libraries_

Issue Analytics

  • State:closed
  • Created 6 years ago
  • Comments:21 (7 by maintainers)

github_iconTop GitHub Comments

7reactions
trollkotzecommented, Feb 15, 2018

Why is this closed? It seems it is not fixed, or is it? I see neither a fix nor a clear explanation.

6reactions
kolbmacommented, Apr 13, 2018

@dherges should this really be closed?

Read more comments on GitHub >

github_iconTop Results From Across the Web

Bountysource
StaticInjectionError for service after migrating to Angular 5. // Solution: `--preserve-symlinks`
Read more >
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 >
Workspace and project file structure - Angular
The following command creates a workspace with all of the workspace-wide configuration files, but no root-level application. content_copy ng new my-workspace ...
Read more >
Ng build --prod 不工作angular 8, Ng build --prod 失败, Ng build ...
Angular5 应用程序在使用ng build --prod 进行生产构建后失败. 解析模块时不要使用真实路径。如果未设置,则如果设置了NodeJS 选项--preserve-symlinks,则默认为true ...
Read more >
Upgrade Angular 5 app to Angular 6 with Visual Studio 2017
First, Update the Angular CLI to the latest version globally using following command: · Next, we need to update Angular CLI local version ......
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