角度生成--prod,错误NullInjectorError:StaticInjectorError(u)[class {constructor(t,e,n,i,s)

时间:2019-07-01 01:49:32

标签: angular deployment

该项目在开发模式下运行良好。

NG build --prod可以正常工作并生成文件,但打开链接后会出错。

如何查找错误所在。

构建脚本:

ng build --prod --output-hashing none --output-path ../backend/src/static/ang --deploy-url /static/ --source-map
core.js.pre-build-optimizer.js:7187 ERROR NullInjectorError: 

NullInjectorError: StaticInjectorError(u)[class{constructor(t,e,n,i,s){this._overlay=t,this._dir=s,this._hasBackdrop=!1,this._lockPosition=!1,this._growAfterOpen=!1,this._flexibleDimensions=!1,this._push=!1,this._backdropSubscription=o.a.EMPTY,this.viewportMargin=0,this.open=!1,this.backdropClick=new r.m,this.positionChange=new r.m,this.attach=new r.m,this.detach=new r.m,this.overlayKeydown=new r.m,this._templatePortal=new p.f(e,n),this._scrollStrategyFactory=i,this.scrollStrategy=this._scrollStrategyFactory()}get offsetX(){return this._offsetX}set offsetX(t){this._offsetX=t,this._position&&this._updatePositionStrategy(this._position)}get offsetY(){return this._offsetY}set offsetY(t){this._offsetY=t,this._position&&this._updatePositionStrategy(this._position)}get hasBackdrop(){return this._hasBackdrop}set hasBackdrop(t){this._hasBackdrop=Object(i.c)(t)}get lockPosition(){return this._lockPosition}set lockPosition(t){this._lockPosition=Object(i.c)(t)}get flexibleDimensions(){return this._flexibleDimensions}set flexibleDimensions(t){this._flexibleDimensions=Object(i.c)(t)}get growAfterOpen(){return this._growAfterOpen}set growAfterOpen(t){this._growAfterOpen=Object(i.c)(t)}get push(){return this._push}set push(t){this._push=Object(i.c)(t)}get overlayRef(){return this._overlayRef}get dir(){return this._dir?this._dir.value:"ltr"}ngOnDestroy(){this._overlayRef&&this._overlayRef.dispose(),this._backdropSubscription.unsubscribe()}ngOnChanges(t){this._position&&(this._updatePositionStrategy(this._position),this._overlayRef.updateSize({width:this.width,minWidth:this.minWidth,height:this.height,minHeight:this.minHeight}),t.origin&&this.open&&this._position.apply()),t.open&&(this.open?this._attachOverlay():this._detachOverlay())}_createOverlay(){this.positions&&this.positions.length||(this.positions=H),this._overlayRef=this._overlay.create(this._buildConfig()),this._overlayRef.keydownEvents().subscribe(t=>{this.overlayKeydown.next(t),t.keyCode!==f.e||Object(f.n)(t)||(t.preventDefault(),this._detachOverlay())})}_buildConfig(){const t=this._position=this._createPositionStrategy(),e=new k({direction:this._dir,positionStrategy:t,scrollStrategy:this.scrollStrategy,hasBackdrop:this.hasBackdrop});return(this.width||0===this.width)&&(e.width=this.width),(this.height||0===this.height)&&(e.height=this.height),(this.minWidth||0===this.minWidth)&&(e.minWidth=this.minWidth),(this.minHeight||0===this.minHeight)&&(e.minHeight=this.minHeight),this.backdropClass&&(e.backdropClass=this.backdropClass),this.panelClass&&(e.panelClass=this.panelClass),e}_updatePositionStrategy(t){const e=this.positions.map(t=>({originX:t.originX,originY:t.originY,overlayX:t.overlayX,overlayY:t.overlayY,offsetX:t.offsetX||this.offsetX,offsetY:t.offsetY||this.offsetY,panelClass:t.panelClass||void 0}));return t.setOrigin(this.origin.elementRef).withPositions(e).withFlexibleDimensions(this.flexibleDimensions).withPush(this.push).withGrowAfterOpen(this.growAfterOpen).withViewportMargin(this.viewportMargin).withLockedPosition(this.lockPosition)}_createPositionStrategy(){const t=this._overlay.position().flexibleConnectedTo(this.origin.elementRef);return this._updatePositionStrategy(t),t.positionChanges.subscribe(t=>this.positionChange.emit(t)),t}_attachOverlay(){this._overlayRef?this._overlayRef.getConfig().hasBackdrop=this.hasBackdrop:this._createOverlay(),this._overlayRef.hasAttached()||(this._overlayRef.attach(this._templatePortal),this.attach.emit()),this.hasBackdrop?this._backdropSubscription=this._overlayRef.backdropClick().subscribe(t=>{this.backdropClick.emit(t)}):this._backdropSubscription.unsubscribe()}_detachOverlay(){this._overlayRef&&(this._overlayRef.detach(),this.detach.emit()),this._backdropSubscription.unsubscribe()}} -> class{constructor(t,e,n,i,s,l,r,a,o,u){this.scrollStrategies=t,this._overlayContainer=e,this._componentFactoryResolver=n,this._positionBuilder=i,this._keyboardDispatcher=s,this._injector=l,this._ngZone=r,this._document=a,this._directionality=o,this._location=u}create(t){const e=this._createHostElement(),n=this._createPaneElement(e),i=this._createPortalOutlet(n),s=new k(t);return s.direction=s.direction||this._directionality.value,new T(i,e,n,s,this._ngZone,this._keyboardDispatcher,this._document,this._location)}position(){return this._positionBuilder}_createPaneElement(t){const e=this._document.createElement("div");return e.id=`cdk-overlay-${R++}`,e.classList.add("cdk-overlay-pane"),t.appendChild(e),e}_createHostElement(){const t=this._document.createElement("div");return this._overlayContainer.getContainerElement().appendChild(t),t}_createPortalOutlet(t){return this._appRef||(this._appRef=this._injector.get(r.g)),new p.c(t,this._componentFactoryResolver,this._appRef,this._injector)}}]: 
  StaticInjectorError(Platform: core)[class{constructor(t,e,n,i,s){this._overlay=t,this._dir=s,this._hasBackdrop=!1,this._lockPosition=!1,this._growAfterOpen=!1,this._flexibleDimensions=!1,this._push=!1,this._backdropSubscription=o.a.EMPTY,this.viewportMargin=0,this.open=!1,this.backdropClick=new r.m,this.positionChange=new r.m,this.attach=new r.m,this.detach=new r.m,this.overlayKeydown=new r.m,this._templatePortal=new p.f(e,n),this._scrollStrategyFactory=i,this.scrollStrategy=this._scrollStrategyFactory()}get offsetX(){return this._offsetX}set offsetX(t){this._offsetX=t,this._position&&this._updatePositionStrategy(this._position)}get offsetY(){return this._offsetY}set offsetY(t){this._offsetY=t,this._position&&this._updatePositionStrategy(this._position)}get hasBackdrop(){return this._hasBackdrop}set hasBackdrop(t){this._hasBackdrop=Object(i.c)(t)}get lockPosition(){return this._lockPosition}set lockPosition(t){this._lockPosition=Object(i.c)(t)}get flexibleDimensions(){return this._flexibleDimensions}set flexibleDimensions(t){this._flexibleDimensions=Object(i.c)(t)}get growAfterOpen(){return this._growAfterOpen}set growAfterOpen(t){this._growAfterOpen=Object(i.c)(t)}get push(){return this._push}set push(t){this._push=Object(i.c)(t)}get overlayRef(){return this._overlayRef}get dir(){return this._dir?this._dir.value:"ltr"}ngOnDestroy(){this._overlayRef&&this._overlayRef.dispose(),this._backdropSubscription.unsubscribe()}ngOnChanges(t){this._position&&(this._updatePositionStrategy(this._position),this._overlayRef.updateSize({width:this.width,minWidth:this.minWidth,height:this.height,minHeight:this.minHeight}),t.origin&&this.open&&this._position.apply()),t.open&&(this.open?this._attachOverlay():this._detachOverlay())}_createOverlay(){this.positions&&this.positions.length||(this.positions=H),this._overlayRef=this._overlay.create(this._buildConfig()),this._overlayRef.keydownEvents().subscribe(t=>{this.overlayKeydown.next(t),t.keyCode!==f.e||Object(f.n)(t)||(t.preventDefault(),this._detachOverlay())})}_buildConfig(){const t=this._position=this._createPositionStrategy(),e=new k({direction:this._dir,positionStrategy:t,scrollStrategy:this.scrollStrategy,hasBackdrop:this.hasBackdrop});return(this.width||0===this.width)&&(e.width=this.width),(this.height||0===this.height)&&(e.height=this.height),(this.minWidth||0===this.minWidth)&&(e.minWidth=this.minWidth),(this.minHeight||0===this.minHeight)&&(e.minHeight=this.minHeight),this.backdropClass&&(e.backdropClass=this.backdropClass),this.panelClass&&(e.panelClass=this.panelClass),e}_updatePositionStrategy(t){const e=this.positions.map(t=>({originX:t.originX,originY:t.originY,overlayX:t.overlayX,overlayY:t.overlayY,offsetX:t.offsetX||this.offsetX,offsetY:t.offsetY||this.offsetY,panelClass:t.panelClass||void 0}));return t.setOrigin(this.origin.elementRef).withPositions(e).withFlexibleDimensions(this.flexibleDimensions).withPush(this.push).withGrowAfterOpen(this.growAfterOpen).withViewportMargin(this.viewportMargin).withLockedPosition(this.lockPosition)}_createPositionStrategy(){const t=this._overlay.position().flexibleConnectedTo(this.origin.elementRef);return this._updatePositionStrategy(t),t.positionChanges.subscribe(t=>this.positionChange.emit(t)),t}_attachOverlay(){this._overlayRef?this._overlayRef.getConfig().hasBackdrop=this.hasBackdrop:this._createOverlay(),this._overlayRef.hasAttached()||(this._overlayRef.attach(this._templatePortal),this.attach.emit()),this.hasBackdrop?this._backdropSubscription=this._overlayRef.backdropClick().subscribe(t=>{this.backdropClick.emit(t)}):this._backdropSubscription.unsubscribe()}_detachOverlay(){this._overlayRef&&(this._overlayRef.detach(),this.detach.emit()),this._backdropSubscription.unsubscribe()}} -> class{constructor(t,e,n,i,s,l,r,a,o,u){this.scrollStrategies=t,this._overlayContainer=e,this._componentFactoryResolver=n,this._positionBuilder=i,this._keyboardDispatcher=s,this._injector=l,this._ngZone=r,this._document=a,this._directionality=o,this._location=u}create(t){const e=this._createHostElement(),n=this._createPaneElement(e),i=this._createPortalOutlet(n),s=new k(t);return s.direction=s.direction||this._directionality.value,new T(i,e,n,s,this._ngZone,this._keyboardDispatcher,this._document,this._location)}position(){return this._positionBuilder}_createPaneElement(t){const e=this._document.createElement("div");return e.id=`cdk-overlay-${R++}`,e.classList.add("cdk-overlay-pane"),t.appendChild(e),e}_createHostElement(){const t=this._document.createElement("div");return this._overlayContainer.getContainerElement().appendChild(t),t}_createPortalOutlet(t){return this._appRef||(this._appRef=this._injector.get(r.g)),new p.c(t,this._componentFactoryResolver,this._appRef,this._injector)}}]: 
    NullInjectorError: No provider for class{constructor(t,e,n,i,s,l,r,a,o,u){this.scrollStrategies=t,this._overlayContainer=e,this._componentFactoryResolver=n,this._positionBuilder=i,this._keyboardDispatcher=s,this._injector=l,this._ngZone=r,this._document=a,this._directionality=o,this._location=u}create(t){const e=this._createHostElement(),n=this._createPaneElement(e),i=this._createPortalOutlet(n),s=new k(t);return s.direction=s.direction||this._directionality.value,new T(i,e,n,s,this._ngZone,this._keyboardDispatcher,this._document,this._location)}position(){return this._positionBuilder}_createPaneElement(t){const e=this._document.createElement("div");return e.id=`cdk-overlay-${R++}`,e.classList.add("cdk-overlay-pane"),t.appendChild(e),e}_createHostElement(){const t=this._document.createElement("div");return this._overlayContainer.getContainerElement().appendChild(t),t}_createPortalOutlet(t){return this._appRef||(this._appRef=this._injector.get(r.g)),new p.c(t,this._componentFactoryResolver,this._appRef,this._injector)}}!
    at P.get (http://localhost:8000/static/main-es2015.js:1:194303)
    at http://localhost:8000/static/main-es2015.js:1:196469
    at t (http://localhost:8000/static/main-es2015.js:1:196839)
    at G.get (http://localhost:8000/static/main-es2015.js:1:196962)
    at http://localhost:8000/static/main-es2015.js:1:196469
    at t (http://localhost:8000/static/main-es2015.js:1:196839)
    at G.get (http://localhost:8000/static/main-es2015.js:1:196962)
    at ol (http://localhost:8000/static/main-es2015.js:1:243189)
    at Tl.get (http://localhost:8000/static/main-es2015.js:1:251908)
    at Xl (http://localhost:8000/static/main-es2015.js:1:255751)

0 个答案:

没有答案