运行我的项目
ng build --prod --base-href="./"
获取以下错误消息
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)
答案 0 :(得分:4)
我发现很难为图书馆建设者找到有关此错误的信息,所以我将其发布在这里。我们不能仅仅告诉用户升级他们的Angular版本或禁用构建优化。
要使库与@ angular / cli的版本6和7一起正常工作,在构建库时必须导出所有装饰器元数据。为此,请将以下内容添加到您的lib的tsconfig.json
中:
"compilerOptions": {
"emitDecoratorMetadata": true
}
答案 1 :(得分:2)
这不是一个永久性的解决方案,但是我只能使用datepicker在生产中使用它。我去了angular.json中的生产配置,并将buildOptimizer更改为false。
答案 2 :(得分:0)
将 ng-multiselect-dropdown的版本降级为0.2.3 可能会解决此问题。
答案 3 :(得分:0)
只需从包装中删除插入号^符号即可,即
"ng-multiselect-dropdown": "^0.2.3" to "ng-multiselect-dropdown": "0.2.3"
解决了我的问题。