Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/angular/33.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Angular 将UI迁移到NG-ZORRO-ANTD后发生生产构建抛出错误_Angular_Angular8_Ng Zorro Antd - Fatal编程技术网

Angular 将UI迁移到NG-ZORRO-ANTD后发生生产构建抛出错误

Angular 将UI迁移到NG-ZORRO-ANTD后发生生产构建抛出错误,angular,angular8,ng-zorro-antd,Angular,Angular8,Ng Zorro Antd,复制步骤 生产构建成功,但应用程序无法运行 ERROR NullInjectorError: StaticInjectorError(c)[$ -> V]: StaticInjectorError(Platform: core)[$ -> V]: NullInjectorError: No provider for V! at j.get (http://localhost:4200/main.205a39b164af2df4f46e.js:1:257106) at http://l

复制步骤 生产构建成功,但应用程序无法运行

ERROR NullInjectorError: StaticInjectorError(c)[$ -> V]: StaticInjectorError(Platform: core)[$ -> V]: NullInjectorError: No provider for V! at j.get (http://localhost:4200/main.205a39b164af2df4f46e.js:1:257106) at http://localhost:4200/main.205a39b164af2df4f46e.js:1:259276 at t (http://localhost:4200/main.205a39b164af2df4f46e.js:1:259646) at W.get (http://localhost:4200/main.205a39b164af2df4f46e.js:1:259769) at http://localhost:4200/main.205a39b164af2df4f46e.js:1:259276 at t (http://localhost:4200/main.205a39b164af2df4f46e.js:1:259646) at W.get (http://localhost:4200/main.205a39b164af2df4f46e.js:1:259769) at ar (http://localhost:4200/main.205a39b164af2df4f46e.js:1:306022) at zr.get (http://localhost:4200/main.205a39b164af2df4f46e.js:1:314741) at ar (http://localhost:4200/main.205a39b164af2df4f46e.js:1:306022)
在本地运行
ngservice--prod
或构建应用程序
ngservice--prod
然后在服务器上运行时,会引发相同的错误。 在开发模式下运行时,一切都很好,工作正常

core.js.pre-build optimizer.js:7187
文件中抛出错误

依赖关系

"dependencies": {
"@angular/animations": "^8.0.0",
"@angular/cdk": "^7.3.1",
"@angular/common": "~8.0.0",
"@angular/compiler": "~8.0.0",
"@angular/core": "~8.0.0",
"@angular/forms": "~8.0.0",
"@angular/material": "^7.3.1",
"@angular/material-moment-adapter": "^7.3.1",
"@angular/platform-browser": "~8.0.0",
"@angular/platform-browser-dynamic": "~8.0.0",
"@angular/router": "~8.0.0",
"@netbasal/ngx-content-loader": "^2.1.0",
"@ngrx/store": "^7.4.0",
"@types/file-saver": "^2.0.1",
"@types/googlemaps": "^3.30.16",
"acorn": "^6.1.1",
"core-js": "^2.5.4",
"dayjs": "^1.8.15",
"file-saver": "^2.0.2",
"hammerjs": "^2.0.8",
"luxon": "^1.12.0",
"moment": "^2.24.0",
"ng-zorro-antd": "^8.2.1",
"ngx-cookie-service": "^2.1.0",
"ngx-material-timepicker": "^3.0.2",
"ramda": "^0.26.1",
"rxjs": "~6.5.2",
"tslib": "^1.9.0",
"zone.js": "~0.9.1"
},
"devDependencies": {
"@angular-devkit/build-angular": "~0.800.0",
"@angular/cli": "~8.0.0",
"@angular/compiler-cli": "~8.0.0",
"@angular/language-service": "~8.0.0",
"@babel/core": "^7.4.5",
"@compodoc/compodoc": "^1.1.9",
"@storybook/addon-actions": "^5.0.11",
"@storybook/addon-links": "^5.0.11",
"@storybook/addon-notes": "^5.0.11",
"@storybook/addons": "^5.0.11",
"@storybook/angular": "^5.0.11",
"@types/jasmine": "~2.8.8",
"@types/jasminewd2": "~2.0.3",
"@types/node": "~8.9.4",
"babel-loader": "^8.0.6",
"browser-sync": "^2.26.5",
"codelyzer": "^5.0.1",
"husky": "^3.0.5",
"jasmine-core": "~2.99.1",
"jasmine-spec-reporter": "~4.2.1",
"karma": "~3.1.1",
"karma-chrome-launcher": "~2.2.0",
"karma-coverage-istanbul-reporter": "~2.0.1",
"karma-jasmine": "~1.1.2",
"karma-jasmine-html-reporter": "^0.2.2",
"prettier": "1.18.2",
"pretty-quick": "^1.11.1",
"protractor": "~5.4.0",
"ts-node": "~7.0.0",
"tslint": "~5.11.0",
"typescript": "~3.4.5"
}
运行
ngserve--aot
这是用于生产的编译器模式。如果您这样做,您将得到一个可调试错误,并将看到您的导入或提供程序中缺少什么。当您使用“--prod-flag”时,代码是丑陋的,并且模块、变量、类等。。。丢失它的名称。

运行
ngserve--aot
这是用于生产的编译器模式。如果您这样做,您将得到一个可调试错误,并将看到您的导入或提供程序中缺少什么。当您使用“--prod-flag”时,代码是丑陋的,并且模块、变量、类等。。。丢失它的名称。

好的。问题已经解决。 您使用的是角度材质和角度材质的冲突版本。(角度相关性在版本6上,而角度CDK和角度材质相关性在版本7上,版本7需要角度v7。)

你应该:

更新Angular的所有版本

这可以通过运行ng update@angular/core来完成,它应该更新所有角度依赖项

(有关更新命令的更多信息,请查看文档或更新网站)

降低角度CDK和角度材质的版本

这可以通过运行以下命令来实现:

npm i@angular/{cdk,material}'^6.0.0' 此命令应安装CDK和Angular Material的版本6

查看此URL以了解更多信息

确定。问题已经解决。 您使用的是角度材质和角度材质的冲突版本。(角度相关性在版本6上,而角度CDK和角度材质相关性在版本7上,版本7需要角度v7。)

你应该:

更新Angular的所有版本

这可以通过运行ng update@angular/core来完成,它应该更新所有角度依赖项

(有关更新命令的更多信息,请查看文档或更新网站)

降低角度CDK和角度材质的版本

这可以通过运行以下命令来实现:

npm i@angular/{cdk,material}'^6.0.0' 此命令应安装CDK和Angular Material的版本6


查看此URL以了解更多信息

您确定所有依赖项注入都已正确执行吗?我相信是这样,因为我只更改了UI组件..未接触服务等..如果我将导入或其他操作弄糟,我相信在构建过程中会抛出错误,此问题已通过此答案解决。你确定所有的依赖注入都正确吗?我相信是的,因为我只更改了UI组件。没有接触服务等。如果我搞砸了导入或其他事情,我相信在构建过程中会抛出一个错误。这个答案已经解决了。ng zorro antd menu.d.ts.NzSubMenuComponent.html:27错误NullInjectorError:StaticInjectorError(AppModule)[CdkConnectedOverlay->Overlay]:StaticInjectorError(平台:core)[CdkConnectedOverlay->Overlay]:NullInjectorError:没有覆盖的提供程序!ng zorro antd menu.d.ts.NzSubMenuComponent.html:27错误NullInjectorError:StaticInjectorError(AppModule)[CdkConnectedOverlay->Overlay]:StaticInjectorError(平台:core)[CdkConnectedOverlay->Overlay]:NullInjectorError:没有覆盖的提供程序!