Repository navigation
AOT build error Cannot read property 'kind' of undefined #8434
Description
Bug Report or Feature Request (mark with an x)
- [x] bug report -> please search issues before submitting
- [ ] feature request
Versions.
Angular CLI: 1.5.0
Node: 8.5.0
OS: darwin x64
Angular: 5.0.1
... animations, common, compiler, compiler-cli, core, forms
... http, language-service, platform-browser
... platform-browser-dynamic, router
@angular/cdk: 5.0.0-rc0
@angular/cli: 1.5.0
@angular/flex-layout: 2.0.0-beta.10-4905443
@angular/material: 5.0.0-rc0
@angular-devkit/build-optimizer: 0.0.32
@angular-devkit/core: 0.0.20
@angular-devkit/schematics: 0.0.35
@ngtools/json-schema: 1.1.0
@ngtools/webpack: 1.8.0
@schematics/angular: 0.1.2
typescript: 2.4.2
webpack-bundle-analyzer: 2.9.1
webpack: 3.8.1
Repro steps.
rm -rf node_modules/
yarn add @angular/cli@latest -D
ng build --aot
The log given by the failure.
ERROR in Error: TypeError: Cannot read property 'kind' of undefined at nodeCanBeDecorated (/Users/sam/Developer/ng-prime/node_modules/typescript/lib/typescript.js:7805:35) at nodeIsDecorated (/Users/sam/Developer/ng-prime/node_modules/typescript/lib/typescript.js:7825:16) at Object.nodeOrChildIsDecorated (/Users/sam/Developer/ng-prime/node_modules/typescript/lib/typescript.js:7829:16) at isDecoratedClassElement (/Users/sam/Developer/ng-prime/node_modules/typescript/lib/typescript.js:51668:23) at isInstanceDecoratedClassElement (/Users/sam/Developer/ng-prime/node_modules/typescript/lib/typescript.js:51659:20) at Object.filter (/Users/sam/Developer/ng-prime/node_modules/typescript/lib/typescript.js:1652:25) at getDecoratedClassElements (/Users/sam/Developer/ng-prime/node_modules/typescript/lib/typescript.js:51641:23) at generateClassElementDecorationExpressions (/Users/sam/Developer/ng-prime/node_modules/typescript/lib/typescript.js:51815:27) at addClassElementDecorationStatements (/Users/sam/Developer/ng-prime/node_modules/typescript/lib/typescript.js:51804:44) at visitClassDeclaration (/Users/sam/Developer/ng-prime/node_modules/typescript/lib/typescript.js:51131:13) at visitTypeScript (/Users/sam/Developer/ng-prime/node_modules/typescript/lib/typescript.js:50972:28) at visitorWorker (/Users/sam/Developer/ng-prime/node_modules/typescript/lib/typescript.js:50785:24) at sourceElementVisitorWorker (/Users/sam/Developer/ng-prime/node_modules/typescript/lib/typescript.js:50817:28) at saveStateAndInvoke (/Users/sam/Developer/ng-prime/node_modules/typescript/lib/typescript.js:50738:27) at sourceElementVisitor (/Users/sam/Developer/ng-prime/node_modules/typescript/lib/typescript.js:50799:20) at visitNodes (/Users/sam/Developer/ng-prime/node_modules/typescript/lib/typescript.js:49280:48)
Desired functionality.
AOT build should be successful
Mention any other details that might be useful.
The project built fine with AOT enabled with CLI v1.4.9
Activity
DavidDNA commentedon Nov 10, 2017
Same issue here with @angular/cli 1.5.0
Works without aot.
Axure commentedon Nov 15, 2017
Same here, except that it does not work either without AOT. Without AOT, it takes over 140 seconds to build, and throws the following error when actually running:
samalexander commentedon Nov 15, 2017
@Axure it builds successfully for me with
ng build --prod --aot=falseAxure commentedon Nov 15, 2017
I seem to have found out the problem. The problematic code there is:
It seems to fail to find the parent of the node when the node is a property declaration. I suddenly realized that it was the @select decorator from angular-redux, and I'm pretty sure the decorator is valid. So I tried adding the following line to bypass the check.
if (!node.parent) return true;And it turns out to be working.
arsyed04 commentedon Nov 19, 2017
Facing this issue with Angular Cli 1.5.2
Works fine with 1.5.0
Angular Version: 1.5.2
cerebroo commentedon Nov 20, 2017
@arsyed04 - Yup was getting error with Angular Cli 1.5.2 but worked fine when rolled back to 1.5.0
Thanks.
Not sure if it's really needed but my TypeScript version was 2.6.1
arsyed04 commentedon Nov 20, 2017
My typescript version is also same "typescript": "^2.6.1"
elvisbegovic commentedon Nov 20, 2017
same error and my version is
"typescript": "~2.4.2"billcheng commentedon Nov 20, 2017
Same error with cli 1.5.2. Downgraded to 1.5.0 and it worked.
@angular/cli: 1.5.2
@angular/xxxx: 5.0.2
typescript: 2.4.2
danielsogl commentedon Nov 20, 2017
Im having the same error since I use the md-bootstrap project.
1forh commentedon Nov 21, 2017
Getting same error.
@angular/angular-cli 1.5.3
@angular/core 5.0.2
typescript 2.6.1
Running:
ng build --prod --aotProduces:
Edit: I've also narrowed it down to a specific decorator I'm using throughout my app. Removing the instances of the
@Throttle()decorator (fromlodash-decorators) from my app "fixes" my issue.akartynnik commentedon Nov 21, 2017
Same error.
@angular/angular-cli 1.5.0
@angular/core 5.0.2
typescript 2.6.1
Running:
ng build --aot53 remaining items
Temporal fix for AOT build bug - read details for bug description
andrea-spotsoftware commentedon Mar 2, 2018
@morganster this issue is about --aot compilation
front-end-developer commentedon Apr 23, 2018
It still broken
angular cli: 1.7.4
angular version: 5.2.10
typescript: 2.8.3
webpack: 3.11.0
it is not possible to build with: ng build --prod
still breaks with:
TypeError: Cannot read property 'kind' of undefined
kevinbuhmann commentedon Apr 23, 2018
@front-end-developer: TypeScript 2.8.x is not yet supported. Please install a version that matches the Angular compiler's peer dependency: https://github.com/angular/angular/blob/5.2.10/packages/compiler-cli/package.json#L18
front-end-developer commentedon Apr 23, 2018
Thanks for this, now I ran:
npm install typescript@'>=2.4.2 <2.7'
it installed:
"typescript": "^2.6.2"
when i run ng build --prod:
because I saw errors about:
Function calls are not supported in decorators but 'ɵmakeDecorator' was called in 'Component'
'Component' calls 'ɵmakeDecorator'
I changed it to: 2.7.0-rc
that fixed it.
Then i run ng build --prod:
Now it cries:
ERROR in Cannot read property 'kind' of undefined
searched all day to fix that error: but never found a solution has anybody ever found a solution this this error?
my nvm lists has:
8.9.4, 8.9.0, 7.6.0 & 7.10.1
front-end-developer commentedon Apr 26, 2018
So this fix worked for me:
I was using nvm (node version manager) and switching between node versions to find the solutions,
you have to select the right version of node, I have 64bit version and node-sass was asking for 32bit version.
I had to do: npm rebuild node-sass
but then after a build I had that error, during node-sass rebuild I noticed it was saying it could not find python 2.
So I ran the command from powershell as administrator:
npm --add-python-to-path='true' --debug install --global windows-build-tools
npm install --global node-gyp
then I switch to a 32 bit node version:
nvm use 7.x.x 32
you can check your nvm version with the command:
nvm list
7.6.0 (Currently using 32-bit executable)
So that fixed that, then I ran:
npm rebuild node-sass
then tried to find a compatible typescript version that would not torment my production build:
"typescript": "^2.6.2"
that fixed my issues.
front-end-developer commentedon Apr 26, 2018
so the only error I am seeing now is:
Function calls are not supported in decorators but 'ɵmakeDecorator' was called in 'Component'
'Component' calls 'ɵmakeDecorator'
but this is manageable.
juninhocruzg3 commentedon Apr 30, 2018
I had same problem today.
TypeError: Cannot read property 'kind' of undefined (...)...and I fix it just upgrading my Typescript for 2.6.2.
rodrigowindows commentedon Aug 2, 2018
These steps worked for me:
1)Clear package.json with the importat packages for example I have delete my package and insert one by one here is my
albanx commentedon Dec 16, 2018
The problem might be in the
^of the packages. IN my case the problem was typescript version I had"typescript": "^3.1.3",and npm installed version 3.2.2.Changed to
"typescript": "3.1.3",ran npm install and the problem got fixed.EssieShey commentedon Dec 21, 2018
I believe you missed type of chartist package.
Try below:
npm install chartist
gerardcarbo commentedon Feb 6, 2019
Same error in @angular/cli 7.3.0 when running 'ng serve --proxy-config proxy.conf.js --port 4500 -o':
It fails on rebuilding the project when changes are detected. Forcing a new rebuild (changing some code) use to build it correctly.
angular-automatic-lock-bot commentedon Sep 9, 2019
This issue has been automatically locked due to inactivity.
Please file a new issue if you are encountering a similar or related problem.
Read more about our automatic conversation locking policy.
This action has been performed automatically by a bot.