跟随this tutorial。这是我得到的错误。唯一的区别是我正在声明一个指令insteaad组件,虽然它在本地开发中工作正常但是当通过npm安装时它给出了以下内容错误:
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
答案 0 :(得分:1)
我在GitHub问题https://github.com/angular/angular/issues/20101
中找到了答案我必须按照概述将依赖项参数更改为我的组件库的package.json中的peerDependencies。
在该问题中提到了一个非常有用的博客,该问题解决了我的其他问题here's the link to blog
// package.json
...
dependencies: {
"@angular/common": "^2.4.10",
...
}
将更改为:
// package.json
...
peerDependencies: {
"@angular/common": "^2.4.10",
...
}