Solvedangular cli Using invalid environment causes error in build (was "ERROR in Cannot read property 'length' of undefined")

(on existing project, on windows10) After updating :

  1. cli 31 to rc0
  2. angular packages to rc1
  3. typescript to 2.1.6

I get this insignifiant message error when running ng serve or ng build:

Cannot read property 'length' of undefined
TypeError: Cannot read property 'length' of undefined

What does this mean ?

41 Answers

✔️Accepted Answer

Probably not the same cause but we had the same error (Cannot read property 'length' of undefined) when we accidentally deleted environment.prod.ts during a refactoring process. Restoring this file solved our problem.

Other Answers:

This is a real issue and we will look at it.

Checking out from the repository into a new directory and running npm install fixed the issue - the files are the same. The project in the original directory became suddenly unusable - was not able to find out the reason.

additional info :
I tried in green project "ng new mynewproject --ng4" it work well, it run!

then move all my old /app folder to this new one and I get same error !

apparently the issue is in my code/module ... My project is relativly big I can't remove module by module :(

how achieve this ? can I get more signifiant message error

thanks

Issue was resolved by adding an environment.prod.ts file as stated by @moosetraveller. Thanks!
Though, an error message more appropriate to the cause would be much appreciated.

More Issues: