2

While following this tutorial.This is the error I'm getting.The only difference is that I'm declaring a directive insteaad of component although it's working fine in local developement but when installed through npm it gives the following error:

Error: StaticInjectorError(AppModule)[ApplicationRef -> NgZone]: 
  StaticInjectorError(Platform: core)[ApplicationRef -> NgZone]: 
    NullInjectorError: No provider for NgZone!
    at NullInjector.get (VM1509 core.umd.js:1063)
    at resolveToken (VM1509 core.umd.js:1316)
    at tryResolveToken (VM1509 core.umd.js:1266)
    at StaticInjector.get (VM1509 core.umd.js:1161)
    at resolveToken (VM1509 core.umd.js:1316)
    at tryResolveToken (VM1509 core.umd.js:1266)
    at StaticInjector.get (VM1509 core.umd.js:1161)
    at resolveNgModuleDep (VM1509 core.umd.js:9322)
    at _createClass (VM1509 core.umd.js:9367)
    at _createProviderInstance$1 (VM1509 core.umd.js:9339)
console.(anonymous function) @ preview-45b825bb367532ab5b87a.js:1
(anonymous) @ main.ts:26
ZoneDelegate.invoke @ zone.js:388
Zone.run @ zone.js:138
(anonymous) @ zone.js:872
ZoneDelegate.invokeTask @ zone.js:421
Zone.runTask @ zone.js:188
drainMicroTaskQueue @ zone.js:595
Promise.then (async)
scheduleMicroTask @ zone.js:578
ZoneDelegate.scheduleTask @ zone.js:410
Zone.scheduleTask @ zone.js:232
Zone.scheduleMicroTask @ zone.js:252
scheduleResolveOrReject @ zone.js:862
ZoneAwarePromise.then @ zone.js:962
PlatformRef.bootstrapModule @ application_ref.ts:275
execute @ main.ts:19
Black Mamba
  • 13,632
  • 6
  • 82
  • 105

1 Answers1

1

I found the answer in a GitHub issue https://github.com/angular/angular/issues/20101

I had to change the dependencies parameter to peerDependencies in the package.json of my component library as outlined.

A very helpful blog was referred in that issue which fixed my other problems as well here's the link to blog

// package.json
...
dependencies: {
  "@angular/common": "^2.4.10",
  ...
}

Will be changed to:

// package.json
...
peerDependencies: {
  "@angular/common": "^2.4.10",
  ...
}
Black Mamba
  • 13,632
  • 6
  • 82
  • 105