为什么DI在生产中失败但在调试中没有失败?

时间:2017-03-31 11:40:56

标签: angular typescript meteor angular-meteor

所以,我在我的Angular Meteor应用程序中遇到了一个只有生产的错误,其代码如下:

export class NavComponent extends FacebookLoginPartial {
    constructor(router : Router) {
        super(router);
    }
}

export class FacebookLoginPartial {      
    constructor(protected router : Router) {}

    ...
}

错误为Error: Can't resolve all parameters for t,应用程序完全失败。正如我所提到的,这只发生在生产中(即使用meteor deploy --debug部署或使用meteor --production部署)。我意识到这可能是我对依赖注入的理解失败但我不知道出了什么问题,或者为什么它只是在生产中失败。

无论如何,我通过执行以下操作来修复它:

export class NavComponent extends FacebookLoginPartial {
    constructor(protected router : Router) {
        super();
    }
}

export class FacebookLoginPartial {    
    protected router : Router;

    constructor() {}

    ...
}

这里值得的是完整的堆栈:

"Error: Can't resolve all parameters for t: (?).
    at d (http://localhost:3000/0effe9726410827977b94b8d72efd44b2919c3e6.js?meteor_js_resource=true:22:12329)
    at e [as constructor] (http://localhost:3000/0effe9726410827977b94b8d72efd44b2919c3e6.js?meteor_js_resource=true:25:10456)
    at new e (http://localhost:3000/0effe9726410827977b94b8d72efd44b2919c3e6.js?meteor_js_resource=true:25:12091)
    at t._getDependenciesMetadata (http://localhost:3000/0effe9726410827977b94b8d72efd44b2919c3e6.js?meteor_js_resource=true:31:3954)
    at t._getTypeMetadata (http://localhost:3000/0effe9726410827977b94b8d72efd44b2919c3e6.js?meteor_js_resource=true:31:2296)
    at t.getNonNormalizedDirectiveMetadata (http://localhost:3000/0effe9726410827977b94b8d72efd44b2919c3e6.js?meteor_js_resource=true:30:28066)
    at t._loadDirectiveMetadata (http://localhost:3000/0effe9726410827977b94b8d72efd44b2919c3e6.js?meteor_js_resource=true:30:25758)
    at http://localhost:3000/0effe9726410827977b94b8d72efd44b2919c3e6.js?meteor_js_resource=true:30:29255
    at Array.forEach (native)
    at t.loadNgModuleDirectiveAndPipeMetadata (http://localhost:3000/0effe9726410827977b94b8d72efd44b2919c3e6.js?meteor_js_resource=true:30:29227)
    at http://localhost:3000/0effe9726410827977b94b8d72efd44b2919c3e6.js?meteor_js_resource=true:34:9473
    at Array.forEach (native)
    at t._loadModules (http://localhost:3000/0effe9726410827977b94b8d72efd44b2919c3e6.js?meteor_js_resource=true:34:9426)
    at t._compileModuleAndComponents (http://localhost:3000/0effe9726410827977b94b8d72efd44b2919c3e6.js?meteor_js_resource=true:34:8904)
    at t.compileModuleAsync (http://localhost:3000/0effe9726410827977b94b8d72efd44b2919c3e6.js?meteor_js_resource=true:34:8342)"

0 个答案:

没有答案