Ng-packagr: How to provide angular core injection tokens

Created on 23 Nov 2017  路  4Comments  路  Source: ng-packagr/ng-packagr

Type of Issue

[ ] Bug Report
[ ] Feature Request
[X] Documentation

Description

No provider for InjectionToken Platform ID! when I run ng serve

image

How To Reproduce

_1. import platfrom id injection token:_
import { PLATFORM_ID } from '@angular/core'

_2. inject it in the constructor of a service & console log it:_

constructor(@Inject(PLATFORM_ID) private platformId) {
console.log(platformId);
}

Expected Behaviour

platformId get's printed to the console without a dependency error.

Version Information

ng-packagr: ^2.0.0-rc.2 and ^1.6.0 gives the same error

image

All 4 comments

have to close this as it turns out to be happening only when you use npm link during development. have to push a new version to npm every few minutes now to test the lib but at least it everything works now.

I also ran into this error, and don't understand it. Why would linking of a library have any side effects on providers for a project. Especially providers from @angular/core?

Publishing just to get around the error is not an acceptable work around. What I don't understand is the nature of the problem. I've been debugging the core.js trying to figure out why this is happening, but so far no luck.

Anyone find a solution, other than rebuilding the library every time you want to run your code?

This issue has been automatically locked due to inactivity. Please file a new issue if you are encountering a similar or related problem.
_This action has been performed automatically by a bot._

Was this page helpful?
0 / 5 - 0 ratings