cannot build when ngx-daterangepicker added

4.1k Views Asked by At

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??

3

There are 3 best solutions below

3
On BEST ANSWER

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"
0
On

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

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

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