'cannot build when ngx-daterangepicker added

when iam adding ngx date rangepicker module to my angular project,cannot build it. it failed with error:

ERROR in ./node_modules/ngx-daterangepicker-material/fesm5/ngx-daterangepicker-material.js Module build failed (from ./node_modules/@angular-devkit/build-optimizer/src/build-optimizer/webpack-loader.js): TypeError: Cannot read property 'kind' of undefined

anybody know what is the problem??



Solution 1:[1]

Finally I have the answer... this issue is with the new version of ngx-daterangepicker release. When I used a lower version, I could build with no issues. Thank you for your support.

Version -

"ngx-daterangepicker-material": "~2.0.2"

Solution 2:[2]

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

This is working while using ng serve but I build the entire angular app using ng build --prod and the issue was the following

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

and as the stackblitz exports doesn't contian environments directory you should resolve the issue either by adding such files or comment this lines on angular.json

second problem was for old version of angular dependencies which stackblitz offers, so I updated them on packages.json to what ng new myApp generates.

"@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"

finally it successfully build using ng build --prod

Solution 3:[3]

Fixed a very similar kind of problem I fixed by upgrading to

"@angular-devkit/build-angular": "^0.803.23",

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 Sunil Garg
Solution 2 HoseinGhanbari
Solution 3 Elikill58