-
Notifications
You must be signed in to change notification settings - Fork 12k
Need more error info - " Cannot read property 'length' of undefined TypeError: Cannot read property 'length' of undefined " #5132
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Comments
Yes @RicardoVaranda I already seen those issues. But I think the reason causing these issus are different from each other. The error causes because of this line In line-series.component.ts i am importing a component file from ngx-charts module to extend it. The import statement cause the error. when i remove this import statement it works good.
Please take a look at the repo. |
Dupe of #5053. It seems like the same issue and it's better to consolidate them in a single place. |
I temporary fixed the issue replacing the code line 14876 in "typescript.js" from: to: |
experienced the random tsc error flu TypeError: Cannot read property 'length' of undefined at createSourceFile (/Users/David/Projects/github/dherges/ng-hal/demo/node_modules/@ngtools/webpack/node_modules/typescript/lib/typescript.js:8980:109) at parseSourceFileWorker (/Users/David/Projects/github/dherges/ng-hal/demo/node_modules/@ngtools/webpack/node_modules/typescript/lib/typescript.js:8940:26) - angular/angular-cli#5053 - swimlane/ngx-charts#217 - angular/angular-cli#5132 - angular/angular#11789
Hello @rafaelmelo007. I have some problem. After replace the code in "typescript.js" returns this error: ERROR in Cannot read property 'getSourceFile' of undefined |
I have this exact same problem as well. Happens when including a module I am developing, like to @ragulmathawa. I have removed all external dependencies and file references from the module just to try, but I still get the same error. I have also double checked that the If I change the line of I'm really stumped as none of the error messages are really indicative of where the error might be. |
Put a console.log(fileName) in your createSourceFile() function and it will show you exactly where is the problem. Mine was environment.ts that was missing. |
I am having the same problem. When I added console.log(fileName) in createSourceFile(), it seems the problem file is: node_modules/@angular/common/index.d.ts Why is it trying to transpile Angular files? How can I disable node_modules from being included in a build? (Or avoid this bug some other way?) |
For what it's worth, I got this error when referencing a d.ts file via: |
After facing a similar unhelpful stack trace myself, i can tell you that for me the issue was a typo in an environments declaration in
Here the file was actually named environment.e2e.ts, so the extra 's' was the root cause. Granted my stack trace wasn't entirely the same as the original in this issue, but maybe running an |
As already suggested by @jdthorpe, I also had the very same issue due to ///<reference in my old code. |
I had the case where environment.ts was missing, and therefore this error was trown. |
It happended with me twice, when I ve renamed a component and the other case when delete one. This was just hiding another error: I forgot rename or delete others imports that was using these files. After rename and restart with ng serve, it works again. |
In my case: After changing the component name i thought that was the problem (wrong references somewhere else in my code). but that was not the case. i forgot that i also changed the names of this "element" in the component:
On my corresponding HTML-page i did NOT change this. There it was:
after changing it to:
my problem was solved |
In My Case I Tried To Get Data From Server And Display It's Lenght In html ... Declar a Variable Wich The Data Saves In It By Array In Constructor like : export class DashboardComponent constructor(){ and in Html : And Its Work 👍 |
I have the same: Another pages have same errors. It working properly if user is authorised. I loss the moment when it starting to happens. |
i Hope i Can Help You But i Described My Personal Experiment,,,
i Wish You Finally Find The Best Solution For Your Issue
Your Friend, Adham
2017-12-22 7:43 GMT+02:00 Roman Bebnev <[email protected]>:
… I have the same:
ListComponent.html:19 ERROR Error: Cannot read property 'length' of null
at viewWrappedDebugError (core.js:9795)
at callWithDebugContext (core.js:15101)
at Object.debugCheckAndUpdateView [as checkAndUpdateView] (core.js:14628)
at ViewRef_.detectChanges (core.js:11605)
at eval (core.js:5913)
at Array.forEach ()
at ApplicationRef.tick (core.js:5913)
at eval (core.js:5746)
at ZoneDelegate.invoke (zone.js:392)
at Object.onInvoke (core.js:4756)
Another pages have same error also but without stack trace.
—
You are receiving this because you commented.
Reply to this email directly, view it on GitHub
<#5132 (comment)>,
or mute the thread
<https://github.com/notifications/unsubscribe-auth/AgCdbOT467F6KLyEV0DwwLnQUxyp1Eetks5tC0GYgaJpZM4MPhMX>
.
|
@AdhamRammadan thanks for response. I had been resolved my issue. Reason was: interceptor tried attach auth header with non-existing token (null). Hard to resolve because angular show view / html based error. Data not exists from wrong-authorised header request. In two words - it can be http / headers error. |
In my case i discovered that my |
I spent some 2 hours but resolved with including environments directory to project after re-install from repo etc. |
@klferreira could you please explain your way in more details |
I solved this problem (error during refactoring test). All is good for angular v4.3.* and v4.4*
|
This issue has been automatically locked due to inactivity. Read more about our automatic conversation locking policy. This action has been performed automatically by a bot. |
OS?
Versions.
Repro steps.
https://github.com/ragulmathawa/cutom-ngx-charts
This is the git repo with code I tried.
The log given by the failure.
Mention any other details that might be useful.
I have seen several issues with same error but for different cases. The error must detailed and the possible cause of undefined variable should be found.
Several issues were closed by downgrading the angular-cli but we need to know the exact reason to prevent future issues.
The text was updated successfully, but these errors were encountered: