Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Cannot read property 'kind' of undefined

run the my project

ng build --prod --base-href="./"

getting below error message

ERROR in ./node_modules/ng-multiselect-dropdown/fesm2015/ng-multiselect-dropdown.js
Module build failed (from ./node_modules/@angular-devkit/build-optimizer/src/build-optimizer/webpack-loader.js):
TypeError: Cannot read property 'kind' of undefined
    at isAngularDecoratorMetadataExpression (/home/gayathri/Desktop/webapp8/node_modules/@angular-devkit/build-optimizer/src/transforms/scrub-file.js:265:35)
    at checkNodeForDecorators (/home/gayathri/Desktop/webapp8/node_modules/@angular-devkit/build-optimizer/src/transforms/scrub-file.js:77:21)
    at visitNodes (/home/gayathri/Desktop/webapp8/node_modules/@angular-devkit/build-optimizer/node_modules/typescript/lib/typescript.js:16514:30)
    at Object.forEachChild (/home/gayathri/Desktop/webapp8/node_modules/@angular-devkit/build-optimizer/node_modules/typescript/lib/typescript.js:16740:24)
    at checkNodeForDecorators (/home/gayathri/Desktop/webapp8/node_modules/@angular-devkit/build-optimizer/src/transforms/scrub-file.js:68:31)
    at visitNode (/home/gayathri/Desktop/webapp8/node_modules/@angular-devkit/build-optimizer/node_modules/typescript/lib/typescript.js:16505:24)
    at Object.forEachChild (/home/gayathri/Desktop/webapp8/node_modules/@angular-devkit/build-optimizer/node_modules/typescript/lib/typescript.js:16635:21)
    at checkNodeForDecorators (/home/gayathri/Desktop/webapp8/node_modules/@angular-devkit/build-optimizer/src/transforms/scrub-file.js:68:31)
    at visitNode (/home/gayathri/Desktop/webapp8/node_modules/@angular-devkit/build-optimizer/node_modules/typescript/lib/typescript.js:16505:24)
    at Object.forEachChild (/home/gayathri/Desktop/webapp8/node_modules/@angular-devkit/build-optimizer/node_modules/typescript/lib/typescript.js:16703:24)
    at checkNodeForDecorators (/home/gayathri/Desktop/webapp8/node_modules/@angular-devkit/build-optimizer/src/transforms/scrub-file.js:68:31)
    at visitNode (/home/gayathri/Desktop/webapp8/node_modules/@angular-devkit/build-optimizer/node_modules/typescript/lib/typescript.js:16505:24)
    at Object.forEachChild (/home/gayathri/Desktop/webapp8/node_modules/@angular-devkit/build-optimizer/node_modules/typescript/lib/typescript.js:16692:24)
    at checkNodeForDecorators (/home/gayathri/Desktop/webapp8/node_modules/@angular-devkit/build-optimizer/src/transforms/scrub-file.js:68:31)
    at visitNode (/home/gayathri/Desktop/webapp8/node_modules/@angular-devkit/build-optimizer/node_modules/typescript/lib/typescript.js:16505:24)
    at Object.forEachChild (/home/gayathri/Desktop/webapp8/node_modules/@angular-devkit/build-optimizer/node_modules/typescript/lib/typescript.js:16599:21)
like image 673
gayathri bindela Avatar asked Nov 04 '19 13:11

gayathri bindela


3 Answers

Not a permanent solution, but I was getting this in production only with datepicker. I went to the production configuration in angular.json and changed buildOptimizer to false.

like image 147
Bel Avatar answered Nov 13 '22 16:11

Bel


I found it really hard to find information about this error for library builders, so I'm posting it here. We can't just tell the users to upgrade their Angular's versions or disable build optimization.

For a library to work well with versions 6 and 7 of @angular/cli, you must export all decorators metadata when building the library. To do that, add the following to the tsconfig.json of your lib:

"compilerOptions": {
  "emitDecoratorMetadata": true
}
like image 5
Tiago Peres França Avatar answered Nov 13 '22 14:11

Tiago Peres França


Downgrading the version of ng-multiselect-dropdown to 0.2.3 might solve the issue.

like image 1
Sam Avatar answered Nov 13 '22 14:11

Sam