0

当我将 ngx 日期范围选择器模块添加到我的角度项目时,无法构建它。它失败并出现错误:

./node_modules/ngx-daterangepicker-material/fesm5/ngx-daterangepicker-material.js 中的错误模块构建失败(来自 ./node_modules/@angular-devkit/build-optimizer/src/build-optimizer/webpack-loader.js ):TypeError:无法读取未定义的属性“种类”

有人知道是什么问题吗??

4

2 回答 2

2

终于我有了答案……这个问题与新版本的 ngx-daterangepicker 版本有关。当我使用较低版本时,我可以毫无问题地构建。谢谢您的支持。

版本 -

"ngx-daterangepicker-material": "~2.0.2"
于 2020-04-08T18:24:57.743 回答
0

https://stackblitz.com/edit/angular-ngx-daterangepicker-material-build-problem

这在使用时有效,ng serve但我使用构建整个角度应用程序ng build --prod,问题如下

"fileReplacements": [
                {
                  "replace": "src/environments/environment.ts",
                  "with": "src/environments/environment.prod.ts"
                }
              ],

并且由于 stackblitz 导出不包含环境目录,您应该通过添加此类文件或评论此行来解决问题angular.json

第二个问题是 stackblitz 提供的旧版本的角度依赖,所以我将它们更新packages.jsonng new myApp生成的内容。

"@angular/animations": "~9.0.1",
"@angular/common": "~9.0.1",
"@angular/compiler": "~9.0.1",
"@angular/core": "~9.0.1",
"@angular/forms": "~9.0.1",
"@angular/platform-browser": "~9.0.1",
"@angular/platform-browser-dynamic": "~9.0.1",
"@angular/router": "~9.0.1",

"@angular-devkit/build-angular": "~0.900.2",
"@angular/cli": "~9.0.2",
"@angular/compiler-cli": "~9.0.1",
"@angular/language-service": "~9.0.1",

"typescript": "~3.7.5"

最后它成功构建使用ng build --prod

于 2020-02-21T06:16:42.720 回答