I try to build project with Angular CLI ng build --prod
and I get this error:
ERROR in TypeError: Cannot read property \'kind\' of undefi
This problem occurs by so many cases, one of the major reasons is installed version of @angular/cli is different to globally installed version of @angular/cli Make sure that both are same version. In other cases you have to update the devkit.
Please have a look on these threads, you will get an idea:
I got the same issue and solved it by updating my typescript
dependency to the latest stable version.
In my case, I had version 3.7
and I fixed the issue by upgrading to 3.8
.
Although the question specifically states isParameterPropertyDeclaration
as the source of the error, this question is the only one linked by Google when searching for the following very similar error:
ERROR in ./node_modules/some_library/...
Module build failed (from ./node_modules/@angular-devkit/build-optimizer/src/build-optimizer/webpack-loader.js):
TypeError: Cannot read property 'kind' of undefined
Since I couldn't find any good answer for the error above, I'm posting it here for reference.
If you're using a library affected by this error, you should upgrade your @angular/cli
version to 8 or disable optimization in production mode (to disable optimization, change projects.your_project_name.architect.build.configurations.production.optimization
from true
to false
).
If you're a library owner trying to fully support versions 6 and 7 of Angular, in the tsconfig.json
of your library, set compilerOptions.emitDecoratorMetadata
to true
and recompile. Since now you're exporting all metadata from the decorators, Angular will do .kind
of the exported metadata, fixing the problem where it was undefined
.
Keep in mind now TypeScript 3.6.4 is out. Still, it's ok to read below what wasn't really working.
TypeScript <= 3.6.3
presents this issue, Handle parentless nodes in isParameterPropertyDeclaration.
If you install 3.7
(dev
or the new beta
), it will compile fine.
Note: if you receive an ERROR
on building, regarding the TS version, just disable it via tsconfig
.
For that use disableTypeScriptVersionCheck
"angularCompilerOptions": {
"disableTypeScriptVersionCheck": true
},
"compilerOptions": {
...
Follow the comment's chat if any other problem emerges.
I ran in to this when I was using ng-recaptcha v6.0.2 with angular v6.2.2
For me, the fix was to set buildOptimizer to false in angular.json
"configurations": {
"development": {
"buildOptimizer": false
}
}