TypeError: Cannot read property 'length' of undefined
See original GitHub issueType of Issue
[x] Bug Report
[ ] Feature Request
Description
A bug: please describe the error that you encountered Seems to be when using a component with a templateUrl in 4.0.0 rc2 it always returns this error. Note my component is in a sub package within a regular angular cli project’s generated library.
A feature: please describe your use case and motivation
How To Reproduce
A bug: please include instructions how to reproduce. Issues without reproduction are likely to receive no feedback.
Can you reproduce the error in the integration tests in ng-packagr?
If possible, take a look at the integration/samples
and try to break one of these builds!
Is the error you faced in an application importing the library
Try to break the Angular CLI app in integration/consumers/ng-cli
!
Expected Behaviour
A bug: please describe what behaviour or result you expected
Components with template urls should compile.
A feature: do you have a first draft or an idea how to implement?
Error: : TypeError: Cannot read property 'length' of undefined
at new _Tokenizer (/Users/ed/someproject/node_modules/@angular/compiler/bundles/compiler.umd.js:4535:38)
at tokenize (/Users/ed/someproject/node_modules/@angular/compiler/bundles/compiler.umd.js:4493:12)
at HtmlParser.Parser.parse (/Users/ed/someproject/node_modules/@angular/compiler/bundles/compiler.umd.js:5121:31)
at HtmlParser.parse (/Users/ed/someproject/node_modules/@angular/compiler/bundles/compiler.umd.js:7768:39)
at I18NHtmlParser.parse (/Users/ed/someproject/node_modules/@angular/compiler/bundles/compiler.umd.js:7957:44)
at DirectiveNormalizer._preparseLoadedTemplate (/Users/ed/someproject/node_modules/@angular/compiler/bundles/compiler.umd.js:2035:51)
at /Users/ed/someproject/node_modules/@angular/compiler/bundles/compiler.umd.js:2030:76
at Object.then (/Users/ed/someproject/node_modules/@angular/compiler/bundles/compiler.umd.js:292:77)
at DirectiveNormalizer._preParseTemplate (/Users/ed/someproject/node_modules/@angular/compiler/bundles/compiler.umd.js:2030:26)
at DirectiveNormalizer.normalizeTemplate (/Users/ed/someproject/node_modules/@angular/compiler/bundles/compiler.umd.js:2015:36)
at Object.<anonymous> (/Users/ed/someproject/node_modules/ng-packagr/lib/ngc/compile-source-files.js:53:68)
at Generator.next (<anonymous>)
at /Users/ed/someproject/node_modules/ng-packagr/lib/ngc/compile-source-files.js:7:71
at new Promise (<anonymous>)
at __awaiter (/Users/ed/someproject/node_modules/ng-packagr/lib/ngc/compile-source-files.js:3:12)
at Object.compileSourceFiles (/Users/ed/someproject/node_modules/ng-packagr/lib/ngc/compile-source-files.js:19:12)
at Object.<anonymous> (/Users/ed/someproject/node_modules/ng-packagr/lib/ng-v5/entry-point/ts/compile-ngc.transform.js:28:32)
at Generator.next (<anonymous>)
at /Users/ed/someproject/node_modules/ng-packagr/lib/ng-v5/entry-point/ts/compile-ngc.transform.js:7:71
at new Promise (<anonymous>)
Version Information
$ node_modules/.bin/ng-packagr --version
ng-packagr: 4.0.0-rc.2
@angular/compiler: 6.0.6
rollup: 0.60.7
tsickle: 0.30.0
typescript: 2.7.2
Please include all version numbers that might be relevant, e.g. third-party libraries
Issue Analytics
- State:
- Created 5 years ago
- Comments:15 (3 by maintainers)
Top GitHub Comments
@johnnyprogger you saved my day! The error in my case was with incorrect template paths… Sometimes i think Angular
ng build
should be more verbose for such situationsI ran into this with 1.6.2 RC0 and was able to debug it by adding a console log to the lexer.
In lexer.js, (line 77 as of writing), replace this:
with this:
This showed me the missing file and I was able to fix it within minutes. Hope this helps someone.