Angular 6 cannot compile with `ng serve --prod`
See original GitHub issueOne-line summary [问题简述]
Angular 6 cannot compile with --prod
It worked well with Angular 4 and Angular 5
Version & Environment [版本及环境]
-
ECharts version [ECharts 版本]: “echarts”: “^4.0.2”, “echarts-gl”: “^1.0.1”, “echarts-wordcloud”: “^1.1.3”,
-
OS Version [操作系统类型和版本]: Win10
Other comments [其他信息]
Error in cmd:
ng serve --prod
ERROR in ./node_modules/echarts-gl/dist/echarts-gl.js
Module build failed: TypeError: Cannot read property 'kind' of undefined
at isObjectOrObjectArrayTypeReference (D:\GitFolders\test3\node_modules\@angular-devkit\build-optimizer\node_modules\typescript\lib\typescript.js:20709:34)
at parseNestedTypeLiteral (D:\GitFolders\test3\node_modules\@angular-devkit\build-optimizer\node_modules\typescript\lib\typescript.js:20748:43)
at parseParameterOrPropertyTag (D:\GitFolders\test3\node_modules\@angular-devkit\build-optimizer\node_modules\typescript\lib\typescript.js:20733:85)
at parseTag (D:\GitFolders\test3\node_modules\@angular-devkit\build-optimizer\node_modules\typescript\lib\typescript.js:20572:40)
at D:\GitFolders\test3\node_modules\@angular-devkit\build-optimizer\node_modules\typescript\lib\typescript.js:20447:44
at Object.scanRange (D:\GitFolders\test3\node_modules\@angular-devkit\build-optimizer\node_modules\typescript\lib\typescript.js:8611:26)
at parseJSDocCommentWorker (D:\GitFolders\test3\node_modules\@angular-devkit\build-optimizer\node_modules\typescript\lib\typescript.js:20419:25)
at Object.parseJSDocComment (D:\GitFolders\test3\node_modules\@angular-devkit\build-optimizer\node_modules\typescript\lib\typescript.js:20373:31)
at addJSDocComment (D:\GitFolders\test3\node_modules\@angular-devkit\build-optimizer\node_modules\typescript\lib\typescript.js:15579:68)
at createNodeWithJSDoc (D:\GitFolders\test3\node_modules\@angular-devkit\build-optimizer\node_modules\typescript\lib\typescript.js:15906:17)
at parseObjectLiteralElement (D:\GitFolders\test3\node_modules\@angular-devkit\build-optimizer\node_modules\typescript\lib\typescript.js:18930:24)
at parseListElement (D:\GitFolders\test3\node_modules\@angular-devkit\build-optimizer\node_modules\typescript\lib\typescript.js:16289:20)
at parseDelimitedList (D:\GitFolders\test3\node_modules\@angular-devkit\build-optimizer\node_modules\typescript\lib\typescript.js:16574:31)
at parseObjectLiteralExpression (D:\GitFolders\test3\node_modules\@angular-devkit\build-optimizer\node_modules\typescript\lib\typescript.js:18979:31)
at parsePrimaryExpression (D:\GitFolders\test3\node_modules\@angular-devkit\build-optimizer\node_modules\typescript\lib\typescript.js:18872:28)
at parseMemberExpressionOrHigher (D:\GitFolders\test3\node_modules\@angular-devkit\build-optimizer\node_modules\typescript\lib\typescript.js:18445:30)
ERROR in ./node_modules/echarts/lib/coord/geo/Region.js
Module build failed: TypeError: Cannot read property 'kind' of undefined
at isObjectOrObjectArrayTypeReference (D:\GitFolders\test3\node_modules\@angular-devkit\build-optimizer\node_modules\typescript\lib\typescript.js:20709:34)
at parseNestedTypeLiteral (D:\GitFolders\test3\node_modules\@angular-devkit\build-optimizer\node_modules\typescript\lib\typescript.js:20748:43)
at parseParameterOrPropertyTag (D:\GitFolders\test3\node_modules\@angular-devkit\build-optimizer\node_modules\typescript\lib\typescript.js:20733:85)
at parseTag (D:\GitFolders\test3\node_modules\@angular-devkit\build-optimizer\node_modules\typescript\lib\typescript.js:20572:40)
at D:\GitFolders\test3\node_modules\@angular-devkit\build-optimizer\node_modules\typescript\lib\typescript.js:20447:44
at Object.scanRange (D:\GitFolders\test3\node_modules\@angular-devkit\build-optimizer\node_modules\typescript\lib\typescript.js:8611:26)
at parseJSDocCommentWorker (D:\GitFolders\test3\node_modules\@angular-devkit\build-optimizer\node_modules\typescript\lib\typescript.js:20419:25)
at Object.parseJSDocComment (D:\GitFolders\test3\node_modules\@angular-devkit\build-optimizer\node_modules\typescript\lib\typescript.js:20373:31)
at addJSDocComment (D:\GitFolders\test3\node_modules\@angular-devkit\build-optimizer\node_modules\typescript\lib\typescript.js:15579:68)
at createNodeWithJSDoc (D:\GitFolders\test3\node_modules\@angular-devkit\build-optimizer\node_modules\typescript\lib\typescript.js:15906:17)
at parseObjectLiteralElement (D:\GitFolders\test3\node_modules\@angular-devkit\build-optimizer\node_modules\typescript\lib\typescript.js:18930:24)
at parseListElement (D:\GitFolders\test3\node_modules\@angular-devkit\build-optimizer\node_modules\typescript\lib\typescript.js:16289:20)
at parseDelimitedList (D:\GitFolders\test3\node_modules\@angular-devkit\build-optimizer\node_modules\typescript\lib\typescript.js:16574:31)
at parseObjectLiteralExpression (D:\GitFolders\test3\node_modules\@angular-devkit\build-optimizer\node_modules\typescript\lib\typescript.js:18979:31)
at parsePrimaryExpression (D:\GitFolders\test3\node_modules\@angular-devkit\build-optimizer\node_modules\typescript\lib\typescript.js:18872:28)
at parseMemberExpressionOrHigher (D:\GitFolders\test3\node_modules\@angular-devkit\build-optimizer\node_modules\typescript\lib\typescript.js:18445:30)
ERROR in ./node_modules/zrender/lib/core/BoundingRect.js
Module build failed: TypeError: Cannot read property 'kind' of undefined
at isObjectOrObjectArrayTypeReference (D:\GitFolders\test3\node_modules\@angular-devkit\build-optimizer\node_modules\typescript\lib\typescript.js:20709:34)
at parseNestedTypeLiteral (D:\GitFolders\test3\node_modules\@angular-devkit\build-optimizer\node_modules\typescript\lib\typescript.js:20748:43)
at parseParameterOrPropertyTag (D:\GitFolders\test3\node_modules\@angular-devkit\build-optimizer\node_modules\typescript\lib\typescript.js:20733:85)
at parseTag (D:\GitFolders\test3\node_modules\@angular-devkit\build-optimizer\node_modules\typescript\lib\typescript.js:20572:40)
at D:\GitFolders\test3\node_modules\@angular-devkit\build-optimizer\node_modules\typescript\lib\typescript.js:20447:44
at Object.scanRange (D:\GitFolders\test3\node_modules\@angular-devkit\build-optimizer\node_modules\typescript\lib\typescript.js:8611:26)
at parseJSDocCommentWorker (D:\GitFolders\test3\node_modules\@angular-devkit\build-optimizer\node_modules\typescript\lib\typescript.js:20419:25)
at Object.parseJSDocComment (D:\GitFolders\test3\node_modules\@angular-devkit\build-optimizer\node_modules\typescript\lib\typescript.js:20373:31)
at addJSDocComment (D:\GitFolders\test3\node_modules\@angular-devkit\build-optimizer\node_modules\typescript\lib\typescript.js:15579:68)
at createNodeWithJSDoc (D:\GitFolders\test3\node_modules\@angular-devkit\build-optimizer\node_modules\typescript\lib\typescript.js:15906:17)
at parseObjectLiteralElement (D:\GitFolders\test3\node_modules\@angular-devkit\build-optimizer\node_modules\typescript\lib\typescript.js:18930:24)
at parseListElement (D:\GitFolders\test3\node_modules\@angular-devkit\build-optimizer\node_modules\typescript\lib\typescript.js:16289:20)
at parseDelimitedList (D:\GitFolders\test3\node_modules\@angular-devkit\build-optimizer\node_modules\typescript\lib\typescript.js:16574:31)
at parseObjectLiteralExpression (D:\GitFolders\test3\node_modules\@angular-devkit\build-optimizer\node_modules\typescript\lib\typescript.js:18979:31)
at parsePrimaryExpression (D:\GitFolders\test3\node_modules\@angular-devkit\build-optimizer\node_modules\typescript\lib\typescript.js:18872:28)
at parseMemberExpressionOrHigher (D:\GitFolders\test3\node_modules\@angular-devkit\build-optimizer\node_modules\typescript\lib\typescript.js:18445:30)
ERROR in ./node_modules/echarts/lib/data/Tree.js
Module build failed: TypeError: Cannot read property 'kind' of undefined
at isObjectOrObjectArrayTypeReference (D:\GitFolders\test3\node_modules\@angular-devkit\build-optimizer\node_modules\typescript\lib\typescript.js:20709:34)
at parseNestedTypeLiteral (D:\GitFolders\test3\node_modules\@angular-devkit\build-optimizer\node_modules\typescript\lib\typescript.js:20748:43)
at parseParameterOrPropertyTag (D:\GitFolders\test3\node_modules\@angular-devkit\build-optimizer\node_modules\typescript\lib\typescript.js:20733:85)
at parseTag (D:\GitFolders\test3\node_modules\@angular-devkit\build-optimizer\node_modules\typescript\lib\typescript.js:20572:40)
at D:\GitFolders\test3\node_modules\@angular-devkit\build-optimizer\node_modules\typescript\lib\typescript.js:20447:44
at Object.scanRange (D:\GitFolders\test3\node_modules\@angular-devkit\build-optimizer\node_modules\typescript\lib\typescript.js:8611:26)
at parseJSDocCommentWorker (D:\GitFolders\test3\node_modules\@angular-devkit\build-optimizer\node_modules\typescript\lib\typescript.js:20419:25)
at Object.parseJSDocComment (D:\GitFolders\test3\node_modules\@angular-devkit\build-optimizer\node_modules\typescript\lib\typescript.js:20373:31)
at addJSDocComment (D:\GitFolders\test3\node_modules\@angular-devkit\build-optimizer\node_modules\typescript\lib\typescript.js:15579:68)
at createNodeWithJSDoc (D:\GitFolders\test3\node_modules\@angular-devkit\build-optimizer\node_modules\typescript\lib\typescript.js:15906:17)
at parseStatement (D:\GitFolders\test3\node_modules\@angular-devkit\build-optimizer\node_modules\typescript\lib\typescript.js:19455:53)
at parseListElement (D:\GitFolders\test3\node_modules\@angular-devkit\build-optimizer\node_modules\typescript\lib\typescript.js:16289:20)
at parseList (D:\GitFolders\test3\node_modules\@angular-devkit\build-optimizer\node_modules\typescript\lib\typescript.js:16273:35)
at parseSourceFileWorker (D:\GitFolders\test3\node_modules\@angular-devkit\build-optimizer\node_modules\typescript\lib\typescript.js:15558:37)
at Object.parseSourceFile (D:\GitFolders\test3\node_modules\@angular-devkit\build-optimizer\node_modules\typescript\lib\typescript.js:15429:26)
at Object.createSourceFile (D:\GitFolders\test3\node_modules\@angular-devkit\build-optimizer\node_modules\typescript\lib\typescript.js:15260:29)
Issue Analytics
- State:
- Created 5 years ago
- Reactions:6
- Comments:11 (2 by maintainers)
Top Results From Across the Web
Angular 6 cannot compile with ng serve --prod #8493 - GitHub
The issue comes from webpack optimization so as a temporary fix you can run ng build --prod --build-optimizer=false and the project will compile ......
Read more >ng serve and ng build is not working - Stack Overflow
I tried npm install @angular/cli inside the project. ng serve still not working. what I am missing or doing wrong. here is my...
Read more >ng serve - Angular
Option Description Value Type Default Value
‑‑hmr Enable hot module replacement. boolean false
‑‑host Host to listen on. string localhost
‑‑open Opens the url in default...
Read more >Identify and Fix Build and Deployment Errors in Your Angular ...
Many common build errors may occur as a result of rebuilding your app while using ng serve or running ng build or ng...
Read more >Okta angular can't compile with "ng build --prod" - Questions
We are using Angular 8 with the latest okta-angular package. Using “ng serve” works, but when compiling with “ng build --prod”, the build...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
I have the exact same issue,
Angular 6 will use the echarts using the “@ types/echarts” typings
The issue comes from webpack optimization so as a temporary fix you can run
ng build --prod --build-optimizer=false
and the project will compile (though this is not ideal).Upon further research, I discovered that the issue seems to stem from the version of webpack being used by the angular cli (with cli version 6.0 + uses webpack 4.8.3)
I’m still looking into the issue and trying to find a permanent fix but this is as far as I got so far.
Angular 6 uses typescript. Unless echarts have exposed type definition (like .h header for C program), you will have compilation problem.