Angular-cli: ERROR in Cannot read property 'length' of undefined

Created on 27 Feb 2017  路  11Comments  路  Source: angular/angular-cli

This is a very unhelpful error message. The page seems to momentarily load and then the failure comes up. Please improve the message so that it's easier to figure out the source of the error.

Hash: a4321a331991d1327504                                                            
Time: 12625ms
chunk    {0} main.bundle.js, main.bundle.js.map (main) 161 kB {2} [initial] [rendered]
chunk    {1} styles.bundle.js, styles.bundle.js.map (styles) 19.5 kB {3} [initial]
chunk    {2} vendor.bundle.js, vendor.bundle.js.map (vendor) 4.78 MB [initial] [rendered]
chunk    {3} inline.bundle.js, inline.bundle.js.map (inline) 0 bytes [entry]

ERROR in Cannot read property 'length' of undefined

Stack

errors  @   client?17b0:109
sock.onmessage  @   socket.js:37
EventTarget.dispatchEvent   @   eventtarget.js:51
(anonymous) @   main.js:274
SockJS._transportMessage    @   main.js:272
EventEmitter.emit   @   emitter.js:50
WebSocketTransport.ws.onmessage @   websocket.js:35
wrapFn  @   zone.js:698
ZoneDelegate.invokeTask @   zone.js:265
Zone.runTask    @   zone.js:154
ZoneTask.invoke @   zone.js:335

Please provide us with the following information:

OS?

Windows 7, 8 or 10. Linux (which distribution). Mac OSX (Yosemite? El Capitan?)
El Capitan

Versions.

Please run ng --version. If there's nothing outputted, please run in a Terminal: node --version and paste the result here:
32.3 [25.5]
angular 2.4.4

Repro steps.

Was this an app that wasn't created using the CLI? What change did you do on your code? etc.
can't really pin down, the error started to apear after a massive rebase

The log given by the failure.

Normally this include a stack trace and some more information.

Mention any other details that might be useful.


Thanks! We'll be in touch soon.

Most helpful comment

how can i fix this? please help me
ANDROID_HOME=C:Users........AppDataLocalAndroidsdk1
JAVA_HOME=C:Program FilesJavajdk1.8.0_121
Error: Cannot read property 'length' of undefined

[ERROR] An error occurred while running cordova run android (exit code 1).

All 11 comments

Hi @moniuch, Would you be able to give us the repro steps for this issue?

@RicardoVaranda I wish I could be helpful here but... As I mentioned - it all happened after a massive rebase. Even if I was able to provide my codebase, it wouldn't be even possible to tell where the problem originated, as it was a side-effect of a sequence. I surprisingly could go pass it by rebooting the ng serve process, but it does not change the overall purpose of this ticket - to ask for a more helpful message - as per what was the code or the object that turned to be undefined.

Hey @moniuch, I understand your frustration and completely agree that it should give a more in depth error message to give us developers something more to work with.

This issue is seems very similar to another issue being tracked here:
https://github.com/angular/angular-cli/issues/5053

Better message error output !

I agree!

I got the same issue...how to resolve this please reply anyone resolved the issue
ANDROID_HOME=C:UsersnameAppDataLocalAndroidsdk

JAVA_HOME=C:Program FilesJavajdk1.8.0_102

Error: Cannot read property 'length' of undefined

@angular/cli: 1.0.0
node: 6.9.1
os: win32 ia32
@angular/common: 4.0.2
@angular/compiler: 4.0.2
@angular/compiler-cli: 4.0.2
@angular/core: 4.0.2
@angular/forms: 4.0.2
@angular/http: 4.0.2
@angular/platform-browser: 4.0.2
@angular/platform-browser-dynamic: 4.0.2

@renjit00 I have been hit by this error a bunch of times. I discovered that it helped to keep calm and reboot ng serve.

Facing the same error, I do not know how to resolve it. I am working on a very big project and the error message does not even give a clue on which typescript file to look into. Already spent days into this, hopeless :(

Facing the same error when I try to build ionic cordova build android.
[ERROR] Cordova encountered an error.
You may get more insight by running the Cordova command above directly.

[ERROR] An error occurred while running cordova build android (exit code 1):

    ANDROID_HOME=C:\Users\....\AppData\Local\Android\sdk
    JAVA_HOME=C:\Program Files (x86)\Java\jdk1.8.0_101
    Error: Cannot read property 'length' of undefined

how can i fix this? please help me
ANDROID_HOME=C:Users........AppDataLocalAndroidsdk1
JAVA_HOME=C:Program FilesJavajdk1.8.0_121
Error: Cannot read property 'length' of undefined

[ERROR] An error occurred while running cordova run android (exit code 1).

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._

Was this page helpful?
0 / 5 - 0 ratings

Related issues

hartjo picture hartjo  路  3Comments

IngvarKofoed picture IngvarKofoed  路  3Comments

naveedahmed1 picture naveedahmed1  路  3Comments

gotschmarcel picture gotschmarcel  路  3Comments

MateenKadwaikar picture MateenKadwaikar  路  3Comments