ERROR in Cannot read property 'length' of undefined

(on existing project, on windows10) After updating :

cli 31 to rc0
angular packages to rc1
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 ?

@istiti can you fill out the issue template and give the steps to reproduce? What version of the cli are you updating from?

@deebloo please apologize see point 1 again.
I have no additional info:

Cannot read property 'length' of undefined
TypeError: Cannot read property 'length' of undefined
    at createSourceFile (C:\Users\.....\node_modules\typescript\lib\typescript.js:14552:109)
    at parseSourceFileWorker (C:\Users\.....\node_modules\typescript\lib\typescript.js:14484:26)
    at Object.parseSourceFile (C:\Users\.....\node_modules\typescript\lib\typescript.js:14433:26)
    at Object.createSourceFile (C:\Users\.....\node_modules\typescript\lib\typescript.js:14288:29)
    at WebpackCompilerHost.getSourceFile (C:\Users\.....\node_modules\@ngtools\webpack\src\compiler_host.js:210:27)
    at findSourceFile (C:\Users\.....\node_modules\typescript\lib\typescript.js:63453:29)
    at processSourceFile (C:\Users\.....\node_modules\typescript\lib\typescript.js:63384:27)
    at C:\Users\.....\node_modules\typescript\lib\typescript.js:63494:17
    at Object.forEach (C:\Users\.....\node_modules\typescript\lib\typescript.js:1293:30)
    at processReferencedFiles (C:\Users\.....\node_modules\typescript\lib\typescript.js:63492:16)
    at findSourceFile (C:\Users\.....\node_modules\typescript\lib\typescript.js:63477:21)
    at processImportedModules (C:\Users\.....\node_modules\typescript\lib\typescript.js:63600:25)
    at findSourceFile (C:\Users\.....\node_modules\typescript\lib\typescript.js:63481:17)
    at processSourceFile (C:\Users\.....\node_modules\typescript\lib\typescript.js:63384:27)
    at processRootFile (C:\Users\.....\node_modules\typescript\lib\typescript.js:63271:13)
    at C:\Users\.....\node_modules\typescript\lib\typescript.js:62620:60
    at Object.forEach (C:\Users\.....\node_modules\typescript\lib\typescript.js:1293:30)
    at Object.createProgram (C:\Users\.....\node_modules\typescript\lib\typescript.js:62620:16)
    at AotPlugin._setupOptions (C:\Users\.....\node_modules\@ngtools\webpack\src\plugin.js:124:28)
    at new AotPlugin (C:\Users\.....\node_modules\@ngtools\webpack\src\plugin.js:23:14)
    at _createAotPlugin (C:\Users\.....\node_modules\@angular\cli\models\webpack-configs\typescript.js:55:12)
    at Object.exports.getNonAotConfig (C:\Users\.....\node_modules\@angular\cli\models\webpack-configs\typescript.js:70:19)
    at NgCliWebpackConfig.buildConfig (C:\Users\.....\node_modules\@angular\cli\models\webpack-config.js:27:37)
    at Class.run (C:\Users\.....\node_modules\@angular\cli\tasks\serve.js:37:98)
    at check_port_1.checkPort.then.port (C:\Users\.....\node_modules\@angular\cli\commands\serve.js:103:26)
    at process._tickCallback (internal/process/next_tick.js:103:7)

Did you use ng new to create the project?
If so, make sure that you kept all original arrays in .angular-cli.json configuration like assets, styles and scripts. I received mistake as you do, because I removed assets option from .angular-cli.json.

@metamaker no I don't use ng new I have assets styles and scripts as array.
I try on exisiting project running angular 2.4.8 ith cli31 to update to cli-rc0 and angular rc1 !

Provide your .angular-cli.json, please.

https://gist.github.com/istiti/e544744f16480829416e62b32167051e

Your .angular-cli.json looks ok, not sure what is wrong. Maybe someone else will be able to you ;) .

additional info :
I tried in green project "ng new mynewproject --ng4" 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

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

Additionals infos:
Yes of course I always use Renderer and
Thanks, actually can't move...
Cc @hansl

@isiti can you provide a repository or some sort of code sample that we could use to reproduce? Maybe your package.json might be enough, if you're okay to share that.

Will do it tomorrow at 7AM (UTC +1)
Thanks coz can't move (actually blocked)
@Hansl

I was experiencing the same issue here and after I rolled typescript back from 2.2.1 to 2.0.10 that seemed to fix it.

@hansl here you are https://gist.github.com/istiti/f97eb83c6d18fd1d23965e4a3325033e
@trentmswanson  after passing from 2.1.6 to 2.0.10 I get another error :

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

after when I update typescript from 2.0.10 to 2.2.1 I get same error as in 2.1.6

Cannot read property 'length' of undefined

The strange thing here: the project with angular-cli RC1 was working fine till executing the first ng build --target=production (maybe just a coincidence). Since then the project is broken. ng serve gives the same error now.
When I setup a new project, it is possible to build.
I removed and reinstalled angular-cli like documented (including node_modules) - the same. Also downgraded Typescript to 2.0.10 like the default for a blank project and took all possible settings of a blank project.

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.

As said : I putt in new green cli --ng4 project whole my /app folder and same issue

Apart from the lack of a descriptive message (which is the main focus for this issue), should anyone run into this case, don't panic - chances are that it's just a temporary glitch. I ran into this situation twice and it looked like a local problem with syncing files. The second incident of mine was a bit more clear to me - it followed a git pull. Waiting ca 1 minute and rebooting ng serve cured the app and restored its running state.
FWIW: Since this is ng serve reboot that helps, I would recommend to look closer at the angular-cli.json file - perhaps into the apps.assets item which has been made a mandatory array if I am correct (meaning it does not accept a single string anymore).

additional info: same behavior with angular rc2

additional info
with this conf. my project works/compile fine with typescript 2.1.6 here's my working package.json:
@angular/cli: 1.0.0-rc.0
node: 6.9.2
os: win32 x64
@angular/common: 2.4.9
@angular/compiler: 2.4.9
@angular/core: 2.4.9
@angular/forms: 2.4.9
@angular/http: 2.4.9
@angular/platform-browser: 2.4.9
@angular/platform-browser-dynamic: 2.4.9
@angular/router: 3.4.9
@angular/cli: 1.0.0-rc.0
@angular/compiler-cli: 2.4.9

BUT it breaks
when I add these lines to my package.json, I get length undefined:
"@angular/common": ">=4.0.0-beta <5.0.0",
"@angular/compiler": ">=4.0.0-beta <5.0.0",
"@angular/core": ">=4.0.0-beta <5.0.0",
"@angular/forms": ">=4.0.0-beta <5.0.0",
"@angular/http": ">=4.0.0-beta <5.0.0",
"@angular/platform-browser": ">=4.0.0-beta <5.0.0",
"@angular/platform-browser-dynamic": ">=4.0.0-beta <5.0.0",
"@angular/router": ">=4.0.0-beta <5.0.0"

same issue for me.
I get this error only when building/serving with --prod flag:
Cannot read property 'length' of undefined
TypeError: Cannot read property 'length' of undefined
    at createSourceFile (/home/chris/Workspace/echo/node_modules/typescript/lib/typescript.js:14546:109)
    at parseSourceFileWorker (/home/chris/Workspace/echo/node_modules/typescript/lib/typescript.js:14478:26)
    at Object.parseSourceFile (/home/chris/Workspace/echo/node_modules/typescript/lib/typescript.js:14427:26)
    at Object.createSourceFile (/home/chris/Workspace/echo/node_modules/typescript/lib/typescript.js:14282:29)
    at VirtualFileStats.getSourceFile (/home/chris/Workspace/echo/node_modules/@ngtools/webpack/src/compiler_host.js:66:35)
    at WebpackCompilerHost.getSourceFile (/home/chris/Workspace/echo/node_modules/@ngtools/webpack/src/compiler_host.js:213:38)
    at findSourceFile (/home/chris/Workspace/echo/node_modules/typescript/lib/typescript.js:63447:29)
    at processImportedModules (/home/chris/Workspace/echo/node_modules/typescript/lib/typescript.js:63594:25)
    at findSourceFile (/home/chris/Workspace/echo/node_modules/typescript/lib/typescript.js:63475:17)
    at processSourceFile (/home/chris/Workspace/echo/node_modules/typescript/lib/typescript.js:63378:27)
    at processRootFile (/home/chris/Workspace/echo/node_modules/typescript/lib/typescript.js:63265:13)
    at /home/chris/Workspace/echo/node_modules/typescript/lib/typescript.js:62614:60
    at Object.forEach (/home/chris/Workspace/echo/node_modules/typescript/lib/typescript.js:1293:30)
    at Object.createProgram (/home/chris/Workspace/echo/node_modules/typescript/lib/typescript.js:62614:16)
    at AotPlugin._setupOptions (/home/chris/Workspace/echo/node_modules/@ngtools/webpack/src/plugin.js:124:28)
    at new AotPlugin (/home/chris/Workspace/echo/node_modules/@ngtools/webpack/src/plugin.js:23:14)
    at _createAotPlugin (/home/chris/Workspace/echo/node_modules/@angular/cli/models/webpack-configs/typescript.js:55:12)
    at Object.exports.getAotConfig (/home/chris/Workspace/echo/node_modules/@angular/cli/models/webpack-configs/typescript.js:89:19)
    at NgCliWebpackConfig.buildConfig (/home/chris/Workspace/echo/node_modules/@angular/cli/models/webpack-config.js:26:37)
    at Class.run (/home/chris/Workspace/echo/node_modules/@angular/cli/tasks/build.js:27:92)
    at Class.run (/home/chris/Workspace/echo/node_modules/@angular/cli/commands/build.js:143:26)
    at Class.<anonymous> (/home/chris/Workspace/echo/node_modules/@angular/cli/ember-cli/lib/models/command.js:134:17)
    at process._tickCallback (internal/process/next_tick.js:103:7)

I have the same issue on ubuntu 14.04 with node 7.6.0, npm 4.1.2 when running: ng build. works on my windows machine. here is my package.json.
"dependencies": {
    "@angular/common": "^2.4.8",
    "@angular/compiler": "^2.4.8",
    "@angular/core": "^2.4.8",
    "@angular/forms": "^2.4.8",
    "@angular/http": "^2.4.8",
    "@angular/platform-browser": "^2.4.8",
    "@angular/platform-browser-dynamic": "^2.4.8",
    "@angular/router": "^3.4.8",
    "@ngx-translate/core": "^6.0.0",
    "@ngx-translate/http-loader": "0.0.3",
    "bootstrap-sass": "^3.3.6",
    "core-js": "^2.4.1",
    "intl": "^1.2.4",
    "jquery-ui": "^1.12.0",
    "moment": "^2.13.0",
    "ng2-bootstrap": "^1.1.2",
    "ng2-file-upload": "^1.1.0",
    "ng2-toastr": "^1.5.1",
    "ng2-ui-auth": "^6.1.3",
    "node-sass": "^3.7.0",
    "primeng": "^2.0.1",
    "primeui": "^4.1.15",
    "rxjs": "^5.1.0",
    "zone.js": "^0.7.6"
  },
  "devDependencies": {
    "@angular/cli": "^1.0.0-rc.0",
    "@angular/compiler-cli": "^2.4.0",
    "@types/jasmine": "2.5.38",
    "@types/node": "~6.0.60",
    "codelyzer": "~2.0.0",
    "jasmine-core": "~2.5.2",
    "jasmine-spec-reporter": "~3.2.0",
    "karma": "~1.4.1",
    "karma-chrome-launcher": "~2.0.0",
    "karma-cli": "~1.0.1",
    "karma-coverage-istanbul-reporter": "^0.2.0",
    "karma-jasmine": "~1.1.0",
    "karma-jasmine-html-reporter": "^0.2.2",
    "protractor": "~5.1.0",
    "ts-node": "~2.0.0",
    "tslint": "~4.4.2",
    "typescript": "~2.0.0"
  }

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

@moosetraveller Thanks a lot. This actually happened to be the issue. On our staging server we had no environment file set up.

nop, it's not same cause... I have this file under src/environments/environments.prod.ts
cc @moosetraveller

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.

donno why to me  it isn't resolved :S and I have this file inside my project :s

@istiti
content of my environment.prod.ts:
export const environment = {
  production: true,
  silent: false
};

Maybe, there are additional causes for this issue. Cli error message is misleading in this case.

i had the same problem, other cause:
one of my dependencies referenced a .d.ts file which was simply not there (https://github.com/swimlane/ngx-charts/blob/master/release/d3.js#L1) if i run ng build without aot and prod flag, it would try to lookup that file which resultet in that error

@istiti there is a Stackoverflow (http://stackoverflow.com/a/41231897/42659) answer pointing out that the source folder may not be found/readable

I think in many cases this issue is caused when typescript tries to process a file that doesn't exist. In one of my projects it was a missing .d.ts file. In another it was a missing environment ts file. Adding a console.log(fileName)  in the beginning of the createSourceFile function at node_modules/typescript/lib/typescript.js helped me pinpoint the specific file. Remember to remove the changes or just reinstall your node_modules.

guys thanks to solve this bug to me ! i effectivly had this /// reference to .d.ts file not exist anymore in angular4 !
one of my team member import this file accidently, he don't remember why he did this, this file was available before in ng 2.x (i think)
///
in another file he imported isPresent from "@angular/core/src/facade/lang" but this isPresent is now in this path "@angular/core/typings/src/facade/lang";
ps: i still not understand what is this isPresent but good no more this insignifiant error !
I let this issue open until  a team memeber improve  message error
cc @ctaepper @calebkiage , @hansl

Happy to help. :-)

Hi, has anyone solved this?
I am still getting the same error:
Chriss-iMac:dnd-test christarasovs$ ng serve
Cannot read property 'length' of undefined
TypeError: Cannot read property 'length' of undefined
at createSourceFile (/Users/christarasovs/Desktop/dnd-test/node_modules/typescript/lib/typescript.js:8980:109)
at parseSourceFileWorker (/Users/christarasovs/Desktop/dnd-test/node_modules/typescript/lib/typescript.js:8940:26)
at Object.parseSourceFile (/Users/christarasovs/Desktop/dnd-test/node_modules/typescript/lib/typescript.js:8899:26)
at Object.createSourceFile (/Users/christarasovs/Desktop/dnd-test/node_modules/typescript/lib/typescript.js:8727:29)
at WebpackCompilerHost.getSourceFile (/Users/christarasovs/Desktop/dnd-test/node_modules/@ngtools/webpack/src/compiler_host.js:210:27)
at findSourceFile (/Users/christarasovs/Desktop/dnd-test/node_modules/typescript/lib/typescript.js:45859:29)
at processSourceFile (/Users/christarasovs/Desktop/dnd-test/node_modules/typescript/lib/typescript.js:45790:27)
at /Users/christarasovs/Desktop/dnd-test/node_modules/typescript/lib/typescript.js:45901:17
at Object.forEach (/Users/christarasovs/Desktop/dnd-test/node_modules/typescript/lib/typescript.js:1115:30)
at processReferencedFiles (/Users/christarasovs/Desktop/dnd-test/node_modules/typescript/lib/typescript.js:45899:16)
at findSourceFile (/Users/christarasovs/Desktop/dnd-test/node_modules/typescript/lib/typescript.js:45884:21)
at processSourceFile (/Users/christarasovs/Desktop/dnd-test/node_modules/typescript/lib/typescript.js:45790:27)
at processRootFile (/Users/christarasovs/Desktop/dnd-test/node_modules/typescript/lib/typescript.js:45694:13)
at /Users/christarasovs/Desktop/dnd-test/node_modules/typescript/lib/typescript.js:45151:60
at Object.forEach (/Users/christarasovs/Desktop/dnd-test/node_modules/typescript/lib/typescript.js:1115:30)
at Object.createProgram (/Users/christarasovs/Desktop/dnd-test/node_modules/typescript/lib/typescript.js:45151:16)
at AotPlugin._setupOptions (/Users/christarasovs/Desktop/dnd-test/node_modules/@ngtools/webpack/src/plugin.js:124:28)
at new AotPlugin (/Users/christarasovs/Desktop/dnd-test/node_modules/@ngtools/webpack/src/plugin.js:23:14)
at _createAotPlugin (/Users/christarasovs/Desktop/dnd-test/node_modules/@angular/cli/models/webpack-configs/typescript.js:55:12)
at Object.exports.getNonAotConfig (/Users/christarasovs/Desktop/dnd-test/node_modules/@angular/cli/models/webpack-configs/typescript.js:70:19)
at NgCliWebpackConfig.buildConfig (/Users/christarasovs/Desktop/dnd-test/node_modules/@angular/cli/models/webpack-config.js:27:37)
at Class.run (/Users/christarasovs/Desktop/dnd-test/node_modules/@angular/cli/tasks/serve.js:37:98)
at check_port_1.checkPort.then.port (/Users/christarasovs/Desktop/dnd-test/node_modules/@angular/cli/commands/serve.js:103:26)
at process._tickCallback (internal/process/next_tick.js:109:7)
Chriss-iMac:dnd-test christarasovs$ ng build
Cannot read property 'length' of undefined
TypeError: Cannot read property 'length' of undefined
at createSourceFile (/Users/christarasovs/Desktop/dnd-test/node_modules/typescript/lib/typescript.js:8980:109)
at parseSourceFileWorker (/Users/christarasovs/Desktop/dnd-test/node_modules/typescript/lib/typescript.js:8940:26)
at Object.parseSourceFile (/Users/christarasovs/Desktop/dnd-test/node_modules/typescript/lib/typescript.js:8899:26)
at Object.createSourceFile (/Users/christarasovs/Desktop/dnd-test/node_modules/typescript/lib/typescript.js:8727:29)
at WebpackCompilerHost.getSourceFile (/Users/christarasovs/Desktop/dnd-test/node_modules/@ngtools/webpack/src/compiler_host.js:210:27)
at findSourceFile (/Users/christarasovs/Desktop/dnd-test/node_modules/typescript/lib/typescript.js:45859:29)
at processSourceFile (/Users/christarasovs/Desktop/dnd-test/node_modules/typescript/lib/typescript.js:45790:27)
at /Users/christarasovs/Desktop/dnd-test/node_modules/typescript/lib/typescript.js:45901:17
at Object.forEach (/Users/christarasovs/Desktop/dnd-test/node_modules/typescript/lib/typescript.js:1115:30)
at processReferencedFiles (/Users/christarasovs/Desktop/dnd-test/node_modules/typescript/lib/typescript.js:45899:16)
at findSourceFile (/Users/christarasovs/Desktop/dnd-test/node_modules/typescript/lib/typescript.js:45884:21)
at processSourceFile (/Users/christarasovs/Desktop/dnd-test/node_modules/typescript/lib/typescript.js:45790:27)
at processRootFile (/Users/christarasovs/Desktop/dnd-test/node_modules/typescript/lib/typescript.js:45694:13)
at /Users/christarasovs/Desktop/dnd-test/node_modules/typescript/lib/typescript.js:45151:60
at Object.forEach (/Users/christarasovs/Desktop/dnd-test/node_modules/typescript/lib/typescript.js:1115:30)
at Object.createProgram (/Users/christarasovs/Desktop/dnd-test/node_modules/typescript/lib/typescript.js:45151:16)
at AotPlugin._setupOptions (/Users/christarasovs/Desktop/dnd-test/node_modules/@ngtools/webpack/src/plugin.js:124:28)
at new AotPlugin (/Users/christarasovs/Desktop/dnd-test/node_modules/@ngtools/webpack/src/plugin.js:23:14)
at _createAotPlugin (/Users/christarasovs/Desktop/dnd-test/node_modules/@angular/cli/models/webpack-configs/typescript.js:55:12)
at Object.exports.getNonAotConfig (/Users/christarasovs/Desktop/dnd-test/node_modules/@angular/cli/models/webpack-configs/typescript.js:70:19)
at NgCliWebpackConfig.buildConfig (/Users/christarasovs/Desktop/dnd-test/node_modules/@angular/cli/models/webpack-config.js:27:37)
at Class.run (/Users/christarasovs/Desktop/dnd-test/node_modules/@angular/cli/tasks/build.js:26:92)
at Class.run (/Users/christarasovs/Desktop/dnd-test/node_modules/@angular/cli/commands/build.js:143:26)
at Class. (/Users/christarasovs/Desktop/dnd-test/node_modules/@angular/cli/ember-cli/lib/models/command.js:134:17)
at process._tickCallback (internal/process/next_tick.js:109:7)
Chriss-iMac:dnd-test christarasovs$ ng serve
/Users/christarasovs/Desktop/dnd-test/src/app/app.component.ts
<EMAIL_ADDRESS><EMAIL_ADDRESS><EMAIL_ADDRESS><EMAIL_ADDRESS><EMAIL_ADDRESS><EMAIL_ADDRESS><EMAIL_ADDRESS><EMAIL_ADDRESS><EMAIL_ADDRESS><EMAIL_ADDRESS><EMAIL_ADDRESS><EMAIL_ADDRESS><EMAIL_ADDRESS><EMAIL_ADDRESS><EMAIL_ADDRESS><EMAIL_ADDRESS><EMAIL_ADDRESS><EMAIL_ADDRESS><EMAIL_ADDRESS><EMAIL_ADDRESS><EMAIL_ADDRESS><EMAIL_ADDRESS><EMAIL_ADDRESS><EMAIL_ADDRESS><EMAIL_ADDRESS><EMAIL_ADDRESS><EMAIL_ADDRESS><EMAIL_ADDRESS><EMAIL_ADDRESS><EMAIL_ADDRESS><EMAIL_ADDRESS><EMAIL_ADDRESS><EMAIL_ADDRESS><EMAIL_ADDRESS><EMAIL_ADDRESS><EMAIL_ADDRESS><EMAIL_ADDRESS><EMAIL_ADDRESS><EMAIL_ADDRESS><EMAIL_ADDRESS><EMAIL_ADDRESS><EMAIL_ADDRESS><EMAIL_ADDRESS><EMAIL_ADDRESS><EMAIL_ADDRESS><EMAIL_ADDRESS><EMAIL_ADDRESS><EMAIL_ADDRESS><EMAIL_ADDRESS>/Users/christarasovs/Desktop/dnd-test/node_modules/rxjs/Subject.d.ts
/Users/christarasovs/Desktop/dnd-test/node_modules/rxjs/Operator.d.ts
/Users/christarasovs/Desktop/dnd-test/node_modules/rxjs/Subscriber.d.ts
/Users/christarasovs/Desktop/dnd-test/node_modules/rxjs/Observer.d.ts
/Users/christarasovs/Desktop/dnd-test/node_modules/rxjs/Subscription.d.ts
/Users/christarasovs/Desktop/dnd-test/node_modules/rxjs/Observable.d.ts
/Users/christarasovs/Desktop/dnd-test/node_modules/rxjs/observable/IfObservable.d.ts
/Users/christarasovs/Desktop/dnd-test/node_modules/rxjs/observable/ErrorObservable.d.ts
/Users/christarasovs/Desktop/dnd-test/node_modules/rxjs/Scheduler.d.ts
/Users/christarasovs/Desktop/dnd-test/node_modules/rxjs/scheduler/Action.d.ts
<EMAIL_ADDRESS><EMAIL_ADDRESS><EMAIL_ADDRESS><EMAIL_ADDRESS><EMAIL_ADDRESS><EMAIL_ADDRESS><EMAIL_ADDRESS><EMAIL_ADDRESS><EMAIL_ADDRESS><EMAIL_ADDRESS><EMAIL_ADDRESS><EMAIL_ADDRESS><EMAIL_ADDRESS><EMAIL_ADDRESS><EMAIL_ADDRESS><EMAIL_ADDRESS><EMAIL_ADDRESS><EMAIL_ADDRESS><EMAIL_ADDRESS><EMAIL_ADDRESS><EMAIL_ADDRESS><EMAIL_ADDRESS><EMAIL_ADDRESS><EMAIL_ADDRESS><EMAIL_ADDRESS><EMAIL_ADDRESS><EMAIL_ADDRESS><EMAIL_ADDRESS><EMAIL_ADDRESS><EMAIL_ADDRESS><EMAIL_ADDRESS><EMAIL_ADDRESS><EMAIL_ADDRESS><EMAIL_ADDRESS><EMAIL_ADDRESS><EMAIL_ADDRESS><EMAIL_ADDRESS><EMAIL_ADDRESS><EMAIL_ADDRESS><EMAIL_ADDRESS><EMAIL_ADDRESS>/Users/christarasovs/Desktop/dnd-test/src/app/app.module.ts
<EMAIL_ADDRESS><EMAIL_ADDRESS><EMAIL_ADDRESS><EMAIL_ADDRESS><EMAIL_ADDRESS><EMAIL_ADDRESS><EMAIL_ADDRESS><EMAIL_ADDRESS><EMAIL_ADDRESS><EMAIL_ADDRESS><EMAIL_ADDRESS><EMAIL_ADDRESS><EMAIL_ADDRESS><EMAIL_ADDRESS><EMAIL_ADDRESS><EMAIL_ADDRESS><EMAIL_ADDRESS><EMAIL_ADDRESS><EMAIL_ADDRESS><EMAIL_ADDRESS><EMAIL_ADDRESS><EMAIL_ADDRESS><EMAIL_ADDRESS><EMAIL_ADDRESS><EMAIL_ADDRESS><EMAIL_ADDRESS><EMAIL_ADDRESS><EMAIL_ADDRESS><EMAIL_ADDRESS><EMAIL_ADDRESS><EMAIL_ADDRESS><EMAIL_ADDRESS><EMAIL_ADDRESS><EMAIL_ADDRESS><EMAIL_ADDRESS><EMAIL_ADDRESS><EMAIL_ADDRESS><EMAIL_ADDRESS><EMAIL_ADDRESS><EMAIL_ADDRESS><EMAIL_ADDRESS><EMAIL_ADDRESS><EMAIL_ADDRESS><EMAIL_ADDRESS><EMAIL_ADDRESS><EMAIL_ADDRESS><EMAIL_ADDRESS><EMAIL_ADDRESS><EMAIL_ADDRESS><EMAIL_ADDRESS><EMAIL_ADDRESS><EMAIL_ADDRESS><EMAIL_ADDRESS><EMAIL_ADDRESS><EMAIL_ADDRESS><EMAIL_ADDRESS><EMAIL_ADDRESS><EMAIL_ADDRESS><EMAIL_ADDRESS><EMAIL_ADDRESS><EMAIL_ADDRESS><EMAIL_ADDRESS><EMAIL_ADDRESS><EMAIL_ADDRESS><EMAIL_ADDRESS><EMAIL_ADDRESS><EMAIL_ADDRESS><EMAIL_ADDRESS><EMAIL_ADDRESS><EMAIL_ADDRESS><EMAIL_ADDRESS><EMAIL_ADDRESS><EMAIL_ADDRESS><EMAIL_ADDRESS><EMAIL_ADDRESS><EMAIL_ADDRESS><EMAIL_ADDRESS><EMAIL_ADDRESS><EMAIL_ADDRESS><EMAIL_ADDRESS><EMAIL_ADDRESS><EMAIL_ADDRESS><EMAIL_ADDRESS><EMAIL_ADDRESS><EMAIL_ADDRESS><EMAIL_ADDRESS><EMAIL_ADDRESS><EMAIL_ADDRESS><EMAIL_ADDRESS><EMAIL_ADDRESS><EMAIL_ADDRESS><EMAIL_ADDRESS><EMAIL_ADDRESS><EMAIL_ADDRESS><EMAIL_ADDRESS><EMAIL_ADDRESS><EMAIL_ADDRESS><EMAIL_ADDRESS><EMAIL_ADDRESS><EMAIL_ADDRESS><EMAIL_ADDRESS><EMAIL_ADDRESS><EMAIL_ADDRESS><EMAIL_ADDRESS>/Users/christarasovs/Desktop/dnd-test/src/app/dnd/dnd.component.ts
/Users/christarasovs/Desktop/dnd-test/src/app/dnd/text/text.component.ts
/Users/christarasovs/Desktop/dnd-test/src/app/ng2-dnd/config/testing-utils.ts
<EMAIL_ADDRESS>Cannot read property 'length' of undefined
TypeError: Cannot read property 'length' of undefined
at createSourceFile (/Users/christarasovs/Desktop/dnd-test/node_modules/typescript/lib/typescript.js:8982:109)
at parseSourceFileWorker (/Users/christarasovs/Desktop/dnd-test/node_modules/typescript/lib/typescript.js:8942:26)
at Object.parseSourceFile (/Users/christarasovs/Desktop/dnd-test/node_modules/typescript/lib/typescript.js:8901:26)
at Object.createSourceFile (/Users/christarasovs/Desktop/dnd-test/node_modules/typescript/lib/typescript.js:8729:29)
at WebpackCompilerHost.getSourceFile (/Users/christarasovs/Desktop/dnd-test/node_modules/@ngtools/webpack/src/compiler_host.js:210:27)
at findSourceFile (/Users/christarasovs/Desktop/dnd-test/node_modules/typescript/lib/typescript.js:45861:29)
at processSourceFile (/Users/christarasovs/Desktop/dnd-test/node_modules/typescript/lib/typescript.js:45792:27)
at /Users/christarasovs/Desktop/dnd-test/node_modules/typescript/lib/typescript.js:45903:17
at Object.forEach (/Users/christarasovs/Desktop/dnd-test/node_modules/typescript/lib/typescript.js:1116:30)
at processReferencedFiles (/Users/christarasovs/Desktop/dnd-test/node_modules/typescript/lib/typescript.js:45901:16)
at findSourceFile (/Users/christarasovs/Desktop/dnd-test/node_modules/typescript/lib/typescript.js:45886:21)
at processSourceFile (/Users/christarasovs/Desktop/dnd-test/node_modules/typescript/lib/typescript.js:45792:27)
at processRootFile (/Users/christarasovs/Desktop/dnd-test/node_modules/typescript/lib/typescript.js:45696:13)
at /Users/christarasovs/Desktop/dnd-test/node_modules/typescript/lib/typescript.js:45153:60
at Object.forEach (/Users/christarasovs/Desktop/dnd-test/node_modules/typescript/lib/typescript.js:1116:30)
at Object.createProgram (/Users/christarasovs/Desktop/dnd-test/node_modules/typescript/lib/typescript.js:45153:16)
at AotPlugin._setupOptions (/Users/christarasovs/Desktop/dnd-test/node_modules/@ngtools/webpack/src/plugin.js:124:28)
at new AotPlugin (/Users/christarasovs/Desktop/dnd-test/node_modules/@ngtools/webpack/src/plugin.js:23:14)
at _createAotPlugin (/Users/christarasovs/Desktop/dnd-test/node_modules/@angular/cli/models/webpack-configs/typescript.js:55:12)
at Object.exports.getNonAotConfig (/Users/christarasovs/Desktop/dnd-test/node_modules/@angular/cli/models/webpack-configs/typescript.js:70:19)
at NgCliWebpackConfig.buildConfig (/Users/christarasovs/Desktop/dnd-test/node_modules/@angular/cli/models/webpack-config.js:27:37)
at Class.run (/Users/christarasovs/Desktop/dnd-test/node_modules/@angular/cli/tasks/serve.js:37:98)
at check_port_1.checkPort.then.port (/Users/christarasovs/Desktop/dnd-test/node_modules/@angular/cli/commands/serve.js:103:26)
at process._tickCallback (internal/process/next_tick.js:109:7)
Chriss-iMac:dnd-test christarasovs$

@ChrisTarasovs
can you read this tread please because you can find error using this adivce

Adding a console.log(fileName) in the beginning of the createSourceFile function at node_modules/typescript/lib/typescript.js helped me pinpoint the specific file.

So above  function createSourceFile(fileName, sourceText, languageVersion, setParentNodes, scriptKind) {
I have added 	console.log(fileName);
but than I run ng serve and I get the same issue  as I get just the same error.
Don't seem to understand how you can get the ouput of console.log if that is shown in the browser but I can even load the page?
Currently I got
fallbackLoader option has been deprecated - replace with "fallback"
loader option has been deprecated - replace with "use"
fallbackLoader option has been deprecated - replace with "fallback"
loader option has been deprecated - replace with "use"
fallbackLoader option has been deprecated - replace with "fallback"
loader option has been deprecated - replace with "use"
fallbackLoader option has been deprecated - replace with "fallback"
loader option has been deprecated - replace with "use"
Cannot read property 'length' of undefined
TypeError: Cannot read property 'length' of undefined
at createSourceFile (C:\Users\ctarasovs\AppData\Roaming\npm\node_modules\ang
ular-cli\node_modules\typescript\lib\typescript.js:8980:109)
at parseSourceFileWorker (C:\Users\ctarasovs\AppData\Roaming\npm\node_module
s\angular-cli\node_modules\typescript\lib\typescript.js:8940:26)
at Object.parseSourceFile (C:\Users\ctarasovs\AppData\Roaming\npm\node_modul
es\angular-cli\node_modules\typescript\lib\typescript.js:8899:26)
at Object.createSourceFile (C:\Users\ctarasovs\AppData\Roaming\npm\node_modu
les\angular-cli\node_modules\typescript\lib\typescript.js:8727:29)
.....

@ChrisTarasovs your console.log in this file input in your command line not browser
what's your ts version ? give your package.json

@istiti  sure, here is angular-cli.json and package.json

Just to let you know that I am trying this on OS and Win system
On OS I have setup with @angular 2.4.8 and on Win I have setup the latest 2.4.9
Here is the exact steps I tried

Install node latest v7
Install angular cli > npm install -g @angular/cli
Open CMD and via CMD navigate to Desktop > cd Desktop
Create an angular project via angular CLI > ng new testNg
Navigate to project > cd  testing
Run ng serve to launch > ng serve ( response all good, page loaded)
Navigate to app to add the code from github > cd src/app
Clone from github using SSH into the app folder > git clone git@github.com:akserg/ng2-dnd.git
Run ng server to launch > ng serve ( errors)
Found out I had a missing typescript, so install typescript > npm install typescript –save
Fount out that rxjs not installed  > npm install rxjs –save
Ng serve> still error

Currently with the files above here is my win setup also
>npm --version
4.1.2
>ng --version
angular-cli: 1.0.0-beta.28.3
node: 7.7.1
os: win32 x64
@angular/common: 2.4.9
@angular/compiler: 2.4.9
@angular/core: 2.4.9
@angular/forms: 2.4.9
@angular/http: 2.4.9
@angular/platform-browser: 2.4.9
@angular/platform-browser-dynamic: 2.4.9
@angular/router: 3.4.9
@angular/compiler-cli: 2.4.9

@ChrisTarasovs  I think the lib you are trying to clone

is not angular-cli project
and maybe not expected to with ng2.4.9
and you can't juste clone everything inside src/app and expect it to works

and you can't juste clone everything inside src/app and expect it to works
but at-least i expect it to build or compile.
Using my json file did u have success to setup ?

anyone solved this?
I'm still getting this error. On my computer it works fine, but when I push it to Heroku, I gives this error. I can't use the approach to console.log the fileName on typescript package because heroku always installs everything again. It worked fine until my last build to heroku (a week ago)

sorry, my bad! after last build, I had installed typings packages, and not saved in typings.json. typescript could not find the definitions

This error seem to have different reasons and different solutions. In my case I had a reference ///<reference path="..\..\..\typings\globals\google.maps\index.d.ts" /> pointing to a file that did not exist.

I fixed this by making sure my main property pointed to my main.ts relative to the root property.  Since my root is set to src and main.ts is at src/app/main.ts I changed my main property to app/main.ts.

@brettatoms, thanks, your solution did the work

@brettatoms. Thanks your solution worked for me with an Ionic 2 project.

Regarding the "missing d.t.s file" issue: can this be reported by Angular CLI and printed to console? Is it possible or should the warning be printed by tsc?

Thanks a lot @brettatoms that seemed to fix my problem.

Having looked at my .angular-cli.json file.
I noticed that I was missing the environments/environment.prod.ts and environments/environment.dev.ts were missing. Adding these files in has fixed this for me.
"environmentSource": "environments/environment.ts",
"environments": {
    "dev": "environments/environment.dev.ts",
    "prod": "environments/environment.prod.ts"
}

I found a way to know which file is missing or with the wrong configuration.
Open the typescript.js (node_modules/typescript/lib/typescript.js) and add a console.log("fileName " + fileName); in the first line of the createSourceFile function, before the error, then you will find which file is missing.
My problem was with the main.ts file. it was looking for src/main.ts and my file was in src/app/main.ts

@robsonmafra yes, this is some way.
However, can the cause be reported by ngc ootb? Is this something that needs to be adressed to the tsc team? Who's responsible to get a better error reporting here?

I had my environment.dev.ts not in git and due to creating a new project from the old it was missing and creating it solved my problem.
thanks guys

Having same issue.... Have no idea how to fix this:

EXCEPTION: Cannot read property 'length' of undefined
ErrorHandler.handleError @ vendor.js:78735
next @ vendor.js:53403
schedulerFn @ vendor.js:55466
SafeSubscriber.__tryOrUnsub @ vendor.js:21253
SafeSubscriber.next @ vendor.js:21202
Subscriber._next @ vendor.js:21144
Subscriber.next @ vendor.js:21108
Subject.next @ vendor.js:46531
EventEmitter.emit @ vendor.js:55452
NgZone.triggerError @ vendor.js:44947
onHandleError @ vendor.js:44908
ZoneDelegate.handleError @ vendor.js:66745
Zone.runTask @ vendor.js:66576
ZoneTask.invoke @ vendor.js:66827
vendor.js:78740 ORIGINAL STACKTRACE:
ErrorHandler.handleError @ vendor.js:78740
next @ vendor.js:53403
schedulerFn @ vendor.js:55466
SafeSubscriber.__tryOrUnsub @ vendor.js:21253
SafeSubscriber.next @ vendor.js:21202
Subscriber._next @ vendor.js:21144
Subscriber.next @ vendor.js:21108
Subject.next @ vendor.js:46531
EventEmitter.emit @ vendor.js:55452
NgZone.triggerError @ vendor.js:44947
onHandleError @ vendor.js:44908
ZoneDelegate.handleError @ vendor.js:66745
Zone.runTask @ vendor.js:66576
ZoneTask.invoke @ vendor.js:66827
vendor.js:78741 TypeError: Cannot read property 'length' of undefined
at SafeSubscriber._complete (http://localhost:5000/dist/main-client.js?v=dqWZf3EPCfwKjJa7Y4PHldIisrN02ESsdLijSRnAy0o:1917:52)
at SafeSubscriber.__tryOrUnsub (http://localhost:5000/dist/vendor.js?v=zXjAceTbWZzNTMXFaXt8RHn0kEuzf0rVAtRzIJqw-9Q:21253:16)
at SafeSubscriber.complete (http://localhost:5000/dist/vendor.js?v=zXjAceTbWZzNTMXFaXt8RHn0kEuzf0rVAtRzIJqw-9Q:21238:26)
at Subscriber._complete (http://localhost:5000/dist/vendor.js?v=zXjAceTbWZzNTMXFaXt8RHn0kEuzf0rVAtRzIJqw-9Q:21151:26)
at Subscriber.complete (http://localhost:5000/dist/vendor.js?v=zXjAceTbWZzNTMXFaXt8RHn0kEuzf0rVAtRzIJqw-9Q:21133:18)
at MapSubscriber.Subscriber._complete (http://localhost:5000/dist/vendor.js?v=zXjAceTbWZzNTMXFaXt8RHn0kEuzf0rVAtRzIJqw-9Q:21151:26)
at MapSubscriber.Subscriber.complete (http://localhost:5000/dist/vendor.js?v=zXjAceTbWZzNTMXFaXt8RHn0kEuzf0rVAtRzIJqw-9Q:21133:18)
at XMLHttpRequest.onLoad (http://localhost:5000/dist/vendor.js?v=zXjAceTbWZzNTMXFaXt8RHn0kEuzf0rVAtRzIJqw-9Q:81460:38)
at ZoneDelegate.invokeTask (http://localhost:5000/dist/vendor.js?v=zXjAceTbWZzNTMXFaXt8RHn0kEuzf0rVAtRzIJqw-9Q:66774:31)
at Object.onInvokeTask (http://localhost:5000/dist/vendor.js?v=zXjAceTbWZzNTMXFaXt8RHn0kEuzf0rVAtRzIJqw-9Q:44878:37)
at ZoneDelegate.invokeTask (http://localhost:5000/dist/vendor.js?v=zXjAceTbWZzNTMXFaXt8RHn0kEuzf0rVAtRzIJqw-9Q:66773:36)
at Zone.runTask (http://localhost:5000/dist/vendor.js?v=zXjAceTbWZzNTMXFaXt8RHn0kEuzf0rVAtRzIJqw-9Q:66573:47)
at XMLHttpRequest.ZoneTask.invoke (http://localhost:5000/dist/vendor.js?v=zXjAceTbWZzNTMXFaXt8RHn0kEuzf0rVAtRzIJqw-9Q:66827:38)
-------------   Elapsed: 126 ms; At: Sun Apr 09 2017 22:28:27 GMT+0100 (GMT Daylight Time)   -------------
at getStacktraceWithUncaughtError (http://localhost:5000/dist/vendor.js?v=zXjAceTbWZzNTMXFaXt8RHn0kEuzf0rVAtRzIJqw-9Q:129957:12) [angular]
at new LongStackTrace (http://localhost:5000/dist/vendor.js?v=zXjAceTbWZzNTMXFaXt8RHn0kEuzf0rVAtRzIJqw-9Q:129951:22) [angular]
at Object.onScheduleTask (http://localhost:5000/dist/vendor.js?v=zXjAceTbWZzNTMXFaXt8RHn0kEuzf0rVAtRzIJqw-9Q:130020:18) [angular]
at ZoneDelegate.scheduleTask (http://localhost:5000/dist/vendor.js?v=zXjAceTbWZzNTMXFaXt8RHn0kEuzf0rVAtRzIJqw-9Q:66754:51) [angular]
at Object.onScheduleTask (http://localhost:5000/dist/vendor.js?v=zXjAceTbWZzNTMXFaXt8RHn0kEuzf0rVAtRzIJqw-9Q:66648:29) [angular]
at ZoneDelegate.scheduleTask (http://localhost:5000/dist/vendor.js?v=zXjAceTbWZzNTMXFaXt8RHn0kEuzf0rVAtRzIJqw-9Q:66754:51) [angular]
at Zone.scheduleTask (http://localhost:5000/dist/vendor.js?v=zXjAceTbWZzNTMXFaXt8RHn0kEuzf0rVAtRzIJqw-9Q:66603:39) [angular]
at Zone.scheduleEventTask (http://localhost:5000/dist/vendor.js?v=zXjAceTbWZzNTMXFaXt8RHn0kEuzf0rVAtRzIJqw-9Q:66620:25) [angular]
at zoneAwareAddListener (http://localhost:5000/dist/vendor.js?v=zXjAceTbWZzNTMXFaXt8RHn0kEuzf0rVAtRzIJqw-9Q:67818:14) [angular]
at XMLHttpRequest.addEventListener (eval at createNamedFn (http://localhost:5000/dist/vendor.js?v=zXjAceTbWZzNTMXFaXt8RHn0kEuzf0rVAtRzIJqw-9Q:67924:17), :3:43) [angular]
at Observable._subscribe (http://localhost:5000/dist/vendor.js?v=zXjAceTbWZzNTMXFaXt8RHn0kEuzf0rVAtRzIJqw-9Q:81505:18) [angular]
at Observable._trySubscribe (http://localhost:5000/dist/vendor.js?v=zXjAceTbWZzNTMXFaXt8RHn0kEuzf0rVAtRzIJqw-9Q:10476:25) [angular]
at Observable.subscribe (http://localhost:5000/dist/vendor.js?v=zXjAceTbWZzNTMXFaXt8RHn0kEuzf0rVAtRzIJqw-9Q:10464:27) [angular]
at MapOperator.call (http://localhost:5000/dist/vendor.js?v=zXjAceTbWZzNTMXFaXt8RHn0kEuzf0rVAtRzIJqw-9Q:46704:23) [angular]
-------------   Elapsed: 75 ms; At: Sun Apr 09 2017 22:28:27 GMT+0100 (GMT Daylight Time)   -------------
at getStacktraceWithUncaughtError (http://localhost:5000/dist/vendor.js?v=zXjAceTbWZzNTMXFaXt8RHn0kEuzf0rVAtRzIJqw-9Q:129957:12) [angular]
at new LongStackTrace (http://localhost:5000/dist/vendor.js?v=zXjAceTbWZzNTMXFaXt8RHn0kEuzf0rVAtRzIJqw-9Q:129951:22) [angular]
at Object.onScheduleTask (http://localhost:5000/dist/vendor.js?v=zXjAceTbWZzNTMXFaXt8RHn0kEuzf0rVAtRzIJqw-9Q:130020:18) [angular]
at ZoneDelegate.scheduleTask (http://localhost:5000/dist/vendor.js?v=zXjAceTbWZzNTMXFaXt8RHn0kEuzf0rVAtRzIJqw-9Q:66754:51) [angular]
at Object.onScheduleTask (http://localhost:5000/dist/vendor.js?v=zXjAceTbWZzNTMXFaXt8RHn0kEuzf0rVAtRzIJqw-9Q:66648:29) [angular]
at ZoneDelegate.scheduleTask (http://localhost:5000/dist/vendor.js?v=zXjAceTbWZzNTMXFaXt8RHn0kEuzf0rVAtRzIJqw-9Q:66754:51) [angular]
at Zone.scheduleTask (http://localhost:5000/dist/vendor.js?v=zXjAceTbWZzNTMXFaXt8RHn0kEuzf0rVAtRzIJqw-9Q:66603:39) [angular]
at Zone.scheduleEventTask (http://localhost:5000/dist/vendor.js?v=zXjAceTbWZzNTMXFaXt8RHn0kEuzf0rVAtRzIJqw-9Q:66620:25) [angular]
at zoneAwareAddListener (http://localhost:5000/dist/vendor.js?v=zXjAceTbWZzNTMXFaXt8RHn0kEuzf0rVAtRzIJqw-9Q:67818:14) [angular]
at XMLHttpRequest.addEventListener (eval at createNamedFn (http://localhost:5000/dist/vendor.js?v=zXjAceTbWZzNTMXFaXt8RHn0kEuzf0rVAtRzIJqw-9Q:67924:17), :3:43) [angular]
at Observable._subscribe (http://localhost:5000/dist/vendor.js?v=zXjAceTbWZzNTMXFaXt8RHn0kEuzf0rVAtRzIJqw-9Q:81505:18) [angular]
at Observable._trySubscribe (http://localhost:5000/dist/vendor.js?v=zXjAceTbWZzNTMXFaXt8RHn0kEuzf0rVAtRzIJqw-9Q:10476:25) [angular]
at Observable.subscribe (http://localhost:5000/dist/vendor.js?v=zXjAceTbWZzNTMXFaXt8RHn0kEuzf0rVAtRzIJqw-9Q:10464:27) [angular]
at MapOperator.call (http://localhost:5000/dist/vendor.js?v=zXjAceTbWZzNTMXFaXt8RHn0kEuzf0rVAtRzIJqw-9Q:46704:23) [angular]
-------------   Elapsed: 22 ms; At: Sun Apr 09 2017 22:28:27 GMT+0100 (GMT Daylight Time)   -------------
at getStacktraceWithUncaughtError (http://localhost:5000/dist/vendor.js?v=zXjAceTbWZzNTMXFaXt8RHn0kEuzf0rVAtRzIJqw-9Q:129957:12) [angular]
at new LongStackTrace (http://localhost:5000/dist/vendor.js?v=zXjAceTbWZzNTMXFaXt8RHn0kEuzf0rVAtRzIJqw-9Q:129951:22) [angular]
at Object.onScheduleTask (http://localhost:5000/dist/vendor.js?v=zXjAceTbWZzNTMXFaXt8RHn0kEuzf0rVAtRzIJqw-9Q:130020:18) [angular]
at ZoneDelegate.scheduleTask (http://localhost:5000/dist/vendor.js?v=zXjAceTbWZzNTMXFaXt8RHn0kEuzf0rVAtRzIJqw-9Q:66754:51) [angular]
at Object.onScheduleTask (http://localhost:5000/dist/vendor.js?v=zXjAceTbWZzNTMXFaXt8RHn0kEuzf0rVAtRzIJqw-9Q:66648:29) [angular]
at ZoneDelegate.scheduleTask (http://localhost:5000/dist/vendor.js?v=zXjAceTbWZzNTMXFaXt8RHn0kEuzf0rVAtRzIJqw-9Q:66754:51) [angular]
at Zone.scheduleTask (http://localhost:5000/dist/vendor.js?v=zXjAceTbWZzNTMXFaXt8RHn0kEuzf0rVAtRzIJqw-9Q:66603:39) [angular]
at Zone.scheduleMicroTask (http://localhost:5000/dist/vendor.js?v=zXjAceTbWZzNTMXFaXt8RHn0kEuzf0rVAtRzIJqw-9Q:66614:25) [angular]
at scheduleResolveOrReject (http://localhost:5000/dist/vendor.js?v=zXjAceTbWZzNTMXFaXt8RHn0kEuzf0rVAtRzIJqw-9Q:67118:14) [angular]
at resolvePromise (http://localhost:5000/dist/vendor.js?v=zXjAceTbWZzNTMXFaXt8RHn0kEuzf0rVAtRzIJqw-9Q:67067:21) [angular]
at http://localhost:5000/dist/vendor.js?v=zXjAceTbWZzNTMXFaXt8RHn0kEuzf0rVAtRzIJqw-9Q:67120:17 [angular]
at Object.onInvokeTask (http://localhost:5000/dist/vendor.js?v=zXjAceTbWZzNTMXFaXt8RHn0kEuzf0rVAtRzIJqw-9Q:44878:37) [angular]
at ZoneDelegate.invokeTask (http://localhost:5000/dist/vendor.js?v=zXjAceTbWZzNTMXFaXt8RHn0kEuzf0rVAtRzIJqw-9Q:66773:36) [angular]
-------------   Elapsed: 4 ms; At: Sun Apr 09 2017 22:28:27 GMT+0100 (GMT Daylight Time)   -------------
at getStacktraceWithUncaughtError (http://localhost:5000/dist/vendor.js?v=zXjAceTbWZzNTMXFaXt8RHn0kEuzf0rVAtRzIJqw-9Q:129957:12) [angular]
at new LongStackTrace (http://localhost:5000/dist/vendor.js?v=zXjAceTbWZzNTMXFaXt8RHn0kEuzf0rVAtRzIJqw-9Q:129951:22) [angular]
at Object.onScheduleTask (http://localhost:5000/dist/vendor.js?v=zXjAceTbWZzNTMXFaXt8RHn0kEuzf0rVAtRzIJqw-9Q:130020:18) [angular]
at ZoneDelegate.scheduleTask (http://localhost:5000/dist/vendor.js?v=zXjAceTbWZzNTMXFaXt8RHn0kEuzf0rVAtRzIJqw-9Q:66754:51) [angular]
at Object.onScheduleTask (http://localhost:5000/dist/vendor.js?v=zXjAceTbWZzNTMXFaXt8RHn0kEuzf0rVAtRzIJqw-9Q:66648:29) [angular]
at ZoneDelegate.scheduleTask (http://localhost:5000/dist/vendor.js?v=zXjAceTbWZzNTMXFaXt8RHn0kEuzf0rVAtRzIJqw-9Q:66754:51) [angular]
at Zone.scheduleTask (http://localhost:5000/dist/vendor.js?v=zXjAceTbWZzNTMXFaXt8RHn0kEuzf0rVAtRzIJqw-9Q:66603:39) [angular]
at Zone.scheduleMicroTask (http://localhost:5000/dist/vendor.js?v=zXjAceTbWZzNTMXFaXt8RHn0kEuzf0rVAtRzIJqw-9Q:66614:25) [angular]
at scheduleResolveOrReject (http://localhost:5000/dist/vendor.js?v=zXjAceTbWZzNTMXFaXt8RHn0kEuzf0rVAtRzIJqw-9Q:67118:14) [angular]
at ZoneAwarePromise.then (http://localhost:5000/dist/vendor.js?v=zXjAceTbWZzNTMXFaXt8RHn0kEuzf0rVAtRzIJqw-9Q:67207:17) [angular]
at new ApplicationInitStatus (http://localhost:5000/dist/vendor.js?v=zXjAceTbWZzNTMXFaXt8RHn0kEuzf0rVAtRzIJqw-9Q:52979:60) [angular]
at AppModuleInjector.createInternal (/AppModule/module.ngfactory.js:346:36) [angular]
at AppModuleInjector.NgModuleInjector.create (http://localhost:5000/dist/vendor.js?v=zXjAceTbWZzNTMXFaXt8RHn0kEuzf0rVAtRzIJqw-9Q:79287:76) [angular]
at NgModuleFactory.create (http://localhost:5000/dist/vendor.js?v=zXjAceTbWZzNTMXFaXt8RHn0kEuzf0rVAtRzIJqw-9Q:79255:18) [angular]
ErrorHandler.handleError @ vendor.js:78741
next @ vendor.js:53403
schedulerFn @ vendor.js:55466
SafeSubscriber.__tryOrUnsub @ vendor.js:21253
SafeSubscriber.next @ vendor.js:21202
Subscriber._next @ vendor.js:21144
Subscriber.next @ vendor.js:21108
Subject.next @ vendor.js:46531
EventEmitter.emit @ vendor.js:55452
NgZone.triggerError @ vendor.js:44947
onHandleError @ vendor.js:44908
ZoneDelegate.handleError @ vendor.js:66745
Zone.runTask @ vendor.js:66576
ZoneTask.invoke @ vendor.js:66827
vendor.js:21257 Uncaught TypeError: Cannot read property 'length' of undefined
at SafeSubscriber._complete (http://localhost:5000/dist/main-client.js?v=dqWZf3EPCfwKjJa7Y4PHldIisrN02ESsdLijSRnAy0o:1917:52)
at SafeSubscriber.__tryOrUnsub (http://localhost:5000/dist/vendor.js?v=zXjAceTbWZzNTMXFaXt8RHn0kEuzf0rVAtRzIJqw-9Q:21253:16)
at SafeSubscriber.complete (http://localhost:5000/dist/vendor.js?v=zXjAceTbWZzNTMXFaXt8RHn0kEuzf0rVAtRzIJqw-9Q:21238:26)
at Subscriber._complete (http://localhost:5000/dist/vendor.js?v=zXjAceTbWZzNTMXFaXt8RHn0kEuzf0rVAtRzIJqw-9Q:21151:26)
at Subscriber.complete (http://localhost:5000/dist/vendor.js?v=zXjAceTbWZzNTMXFaXt8RHn0kEuzf0rVAtRzIJqw-9Q:21133:18)
at MapSubscriber.Subscriber._complete (http://localhost:5000/dist/vendor.js?v=zXjAceTbWZzNTMXFaXt8RHn0kEuzf0rVAtRzIJqw-9Q:21151:26)
at MapSubscriber.Subscriber.complete (http://localhost:5000/dist/vendor.js?v=zXjAceTbWZzNTMXFaXt8RHn0kEuzf0rVAtRzIJqw-9Q:21133:18)
at XMLHttpRequest.onLoad (http://localhost:5000/dist/vendor.js?v=zXjAceTbWZzNTMXFaXt8RHn0kEuzf0rVAtRzIJqw-9Q:81460:38)
at ZoneDelegate.invokeTask (http://localhost:5000/dist/vendor.js?v=zXjAceTbWZzNTMXFaXt8RHn0kEuzf0rVAtRzIJqw-9Q:66774:31)
at Object.onInvokeTask (http://localhost:5000/dist/vendor.js?v=zXjAceTbWZzNTMXFaXt8RHn0kEuzf0rVAtRzIJqw-9Q:44878:37)
at ZoneDelegate.invokeTask (http://localhost:5000/dist/vendor.js?v=zXjAceTbWZzNTMXFaXt8RHn0kEuzf0rVAtRzIJqw-9Q:66773:36)
at Zone.runTask (http://localhost:5000/dist/vendor.js?v=zXjAceTbWZzNTMXFaXt8RHn0kEuzf0rVAtRzIJqw-9Q:66573:47)
at XMLHttpRequest.ZoneTask.invoke (http://localhost:5000/dist/vendor.js?v=zXjAceTbWZzNTMXFaXt8RHn0kEuzf0rVAtRzIJqw-9Q:66827:38)
-------------   Elapsed: 92405 ms; At: Sun Apr 09 2017 22:28:27 GMT+0100 (GMT Daylight Time)   -------------
at getStacktraceWithUncaughtError (http://localhost:5000/dist/vendor.js?v=zXjAceTbWZzNTMXFaXt8RHn0kEuzf0rVAtRzIJqw-9Q:129957:12) [angular]
at new LongStackTrace (http://localhost:5000/dist/vendor.js?v=zXjAceTbWZzNTMXFaXt8RHn0kEuzf0rVAtRzIJqw-9Q:129951:22) [angular]
at Object.onScheduleTask (http://localhost:5000/dist/vendor.js?v=zXjAceTbWZzNTMXFaXt8RHn0kEuzf0rVAtRzIJqw-9Q:130020:18) [angular]
at ZoneDelegate.scheduleTask (http://localhost:5000/dist/vendor.js?v=zXjAceTbWZzNTMXFaXt8RHn0kEuzf0rVAtRzIJqw-9Q:66754:51) [angular]
at Object.onScheduleTask (http://localhost:5000/dist/vendor.js?v=zXjAceTbWZzNTMXFaXt8RHn0kEuzf0rVAtRzIJqw-9Q:66648:29) [angular]
at ZoneDelegate.scheduleTask (http://localhost:5000/dist/vendor.js?v=zXjAceTbWZzNTMXFaXt8RHn0kEuzf0rVAtRzIJqw-9Q:66754:51) [angular]
at Zone.scheduleTask (http://localhost:5000/dist/vendor.js?v=zXjAceTbWZzNTMXFaXt8RHn0kEuzf0rVAtRzIJqw-9Q:66603:39) [angular]
at Zone.scheduleEventTask (http://localhost:5000/dist/vendor.js?v=zXjAceTbWZzNTMXFaXt8RHn0kEuzf0rVAtRzIJqw-9Q:66620:25) [angular]
at zoneAwareAddListener (http://localhost:5000/dist/vendor.js?v=zXjAceTbWZzNTMXFaXt8RHn0kEuzf0rVAtRzIJqw-9Q:67818:14) [angular]
at XMLHttpRequest.addEventListener (eval at createNamedFn (http://localhost:5000/dist/vendor.js?v=zXjAceTbWZzNTMXFaXt8RHn0kEuzf0rVAtRzIJqw-9Q:67924:17), :3:43) [angular]
at Observable._subscribe (http://localhost:5000/dist/vendor.js?v=zXjAceTbWZzNTMXFaXt8RHn0kEuzf0rVAtRzIJqw-9Q:81505:18) [angular]
at Observable._trySubscribe (http://localhost:5000/dist/vendor.js?v=zXjAceTbWZzNTMXFaXt8RHn0kEuzf0rVAtRzIJqw-9Q:10476:25) [angular]
at Observable.subscribe (http://localhost:5000/dist/vendor.js?v=zXjAceTbWZzNTMXFaXt8RHn0kEuzf0rVAtRzIJqw-9Q:10464:27) [angular]
at MapOperator.call (http://localhost:5000/dist/vendor.js?v=zXjAceTbWZzNTMXFaXt8RHn0kEuzf0rVAtRzIJqw-9Q:46704:23) [angular]
-------------   Elapsed: 75 ms; At: Sun Apr 09 2017 22:28:27 GMT+0100 (GMT Daylight Time)   -------------
at getStacktraceWithUncaughtError (http://localhost:5000/dist/vendor.js?v=zXjAceTbWZzNTMXFaXt8RHn0kEuzf0rVAtRzIJqw-9Q:129957:12) [angular]
at new LongStackTrace (http://localhost:5000/dist/vendor.js?v=zXjAceTbWZzNTMXFaXt8RHn0kEuzf0rVAtRzIJqw-9Q:129951:22) [angular]
at Object.onScheduleTask (http://localhost:5000/dist/vendor.js?v=zXjAceTbWZzNTMXFaXt8RHn0kEuzf0rVAtRzIJqw-9Q:130020:18) [angular]
at ZoneDelegate.scheduleTask (http://localhost:5000/dist/vendor.js?v=zXjAceTbWZzNTMXFaXt8RHn0kEuzf0rVAtRzIJqw-9Q:66754:51) [angular]
at Object.onScheduleTask (http://localhost:5000/dist/vendor.js?v=zXjAceTbWZzNTMXFaXt8RHn0kEuzf0rVAtRzIJqw-9Q:66648:29) [angular]
at ZoneDelegate.scheduleTask (http://localhost:5000/dist/vendor.js?v=zXjAceTbWZzNTMXFaXt8RHn0kEuzf0rVAtRzIJqw-9Q:66754:51) [angular]
at Zone.scheduleTask (http://localhost:5000/dist/vendor.js?v=zXjAceTbWZzNTMXFaXt8RHn0kEuzf0rVAtRzIJqw-9Q:66603:39) [angular]
at Zone.scheduleEventTask (http://localhost:5000/dist/vendor.js?v=zXjAceTbWZzNTMXFaXt8RHn0kEuzf0rVAtRzIJqw-9Q:66620:25) [angular]
at zoneAwareAddListener (http://localhost:5000/dist/vendor.js?v=zXjAceTbWZzNTMXFaXt8RHn0kEuzf0rVAtRzIJqw-9Q:67818:14) [angular]
at XMLHttpRequest.addEventListener (eval at createNamedFn (http://localhost:5000/dist/vendor.js?v=zXjAceTbWZzNTMXFaXt8RHn0kEuzf0rVAtRzIJqw-9Q:67924:17), :3:43) [angular]
at Observable._subscribe (http://localhost:5000/dist/vendor.js?v=zXjAceTbWZzNTMXFaXt8RHn0kEuzf0rVAtRzIJqw-9Q:81505:18) [angular]
at Observable._trySubscribe (http://localhost:5000/dist/vendor.js?v=zXjAceTbWZzNTMXFaXt8RHn0kEuzf0rVAtRzIJqw-9Q:10476:25) [angular]
at Observable.subscribe (http://localhost:5000/dist/vendor.js?v=zXjAceTbWZzNTMXFaXt8RHn0kEuzf0rVAtRzIJqw-9Q:10464:27) [angular]
at MapOperator.call (http://localhost:5000/dist/vendor.js?v=zXjAceTbWZzNTMXFaXt8RHn0kEuzf0rVAtRzIJqw-9Q:46704:23) [angular]
-------------   Elapsed: 22 ms; At: Sun Apr 09 2017 22:28:27 GMT+0100 (GMT Daylight Time)   -------------
at getStacktraceWithUncaughtError (http://localhost:5000/dist/vendor.js?v=zXjAceTbWZzNTMXFaXt8RHn0kEuzf0rVAtRzIJqw-9Q:129957:12) [angular]
at new LongStackTrace (http://localhost:5000/dist/vendor.js?v=zXjAceTbWZzNTMXFaXt8RHn0kEuzf0rVAtRzIJqw-9Q:129951:22) [angular]
at Object.onScheduleTask (http://localhost:5000/dist/vendor.js?v=zXjAceTbWZzNTMXFaXt8RHn0kEuzf0rVAtRzIJqw-9Q:130020:18) [angular]
at ZoneDelegate.scheduleTask (http://localhost:5000/dist/vendor.js?v=zXjAceTbWZzNTMXFaXt8RHn0kEuzf0rVAtRzIJqw-9Q:66754:51) [angular]
at Object.onScheduleTask (http://localhost:5000/dist/vendor.js?v=zXjAceTbWZzNTMXFaXt8RHn0kEuzf0rVAtRzIJqw-9Q:66648:29) [angular]
at ZoneDelegate.scheduleTask (http://localhost:5000/dist/vendor.js?v=zXjAceTbWZzNTMXFaXt8RHn0kEuzf0rVAtRzIJqw-9Q:66754:51) [angular]
at Zone.scheduleTask (http://localhost:5000/dist/vendor.js?v=zXjAceTbWZzNTMXFaXt8RHn0kEuzf0rVAtRzIJqw-9Q:66603:39) [angular]
at Zone.scheduleMicroTask (http://localhost:5000/dist/vendor.js?v=zXjAceTbWZzNTMXFaXt8RHn0kEuzf0rVAtRzIJqw-9Q:66614:25) [angular]
at scheduleResolveOrReject (http://localhost:5000/dist/vendor.js?v=zXjAceTbWZzNTMXFaXt8RHn0kEuzf0rVAtRzIJqw-9Q:67118:14) [angular]
at resolvePromise (http://localhost:5000/dist/vendor.js?v=zXjAceTbWZzNTMXFaXt8RHn0kEuzf0rVAtRzIJqw-9Q:67067:21) [angular]
at http://localhost:5000/dist/vendor.js?v=zXjAceTbWZzNTMXFaXt8RHn0kEuzf0rVAtRzIJqw-9Q:67120:17 [angular]
at Object.onInvokeTask (http://localhost:5000/dist/vendor.js?v=zXjAceTbWZzNTMXFaXt8RHn0kEuzf0rVAtRzIJqw-9Q:44878:37) [angular]
at ZoneDelegate.invokeTask (http://localhost:5000/dist/vendor.js?v=zXjAceTbWZzNTMXFaXt8RHn0kEuzf0rVAtRzIJqw-9Q:66773:36) [angular]
-------------   Elapsed: 4 ms; At: Sun Apr 09 2017 22:28:27 GMT+0100 (GMT Daylight Time)   -------------
at getStacktraceWithUncaughtError (http://localhost:5000/dist/vendor.js?v=zXjAceTbWZzNTMXFaXt8RHn0kEuzf0rVAtRzIJqw-9Q:129957:12) [angular]
at new LongStackTrace (http://localhost:5000/dist/vendor.js?v=zXjAceTbWZzNTMXFaXt8RHn0kEuzf0rVAtRzIJqw-9Q:129951:22) [angular]
at Object.onScheduleTask (http://localhost:5000/dist/vendor.js?v=zXjAceTbWZzNTMXFaXt8RHn0kEuzf0rVAtRzIJqw-9Q:130020:18) [angular]
at ZoneDelegate.scheduleTask (http://localhost:5000/dist/vendor.js?v=zXjAceTbWZzNTMXFaXt8RHn0kEuzf0rVAtRzIJqw-9Q:66754:51) [angular]
at Object.onScheduleTask (http://localhost:5000/dist/vendor.js?v=zXjAceTbWZzNTMXFaXt8RHn0kEuzf0rVAtRzIJqw-9Q:66648:29) [angular]
at ZoneDelegate.scheduleTask (http://localhost:5000/dist/vendor.js?v=zXjAceTbWZzNTMXFaXt8RHn0kEuzf0rVAtRzIJqw-9Q:66754:51) [angular]
at Zone.scheduleTask (http://localhost:5000/dist/vendor.js?v=zXjAceTbWZzNTMXFaXt8RHn0kEuzf0rVAtRzIJqw-9Q:66603:39) [angular]
at Zone.scheduleMicroTask (http://localhost:5000/dist/vendor.js?v=zXjAceTbWZzNTMXFaXt8RHn0kEuzf0rVAtRzIJqw-9Q:66614:25) [angular]
at scheduleResolveOrReject (http://localhost:5000/dist/vendor.js?v=zXjAceTbWZzNTMXFaXt8RHn0kEuzf0rVAtRzIJqw-9Q:67118:14) [angular]
at ZoneAwarePromise.then (http://localhost:5000/dist/vendor.js?v=zXjAceTbWZzNTMXFaXt8RHn0kEuzf0rVAtRzIJqw-9Q:67207:17) [angular]
at new ApplicationInitStatus (http://localhost:5000/dist/vendor.js?v=zXjAceTbWZzNTMXFaXt8RHn0kEuzf0rVAtRzIJqw-9Q:52979:60) [angular]
at AppModuleInjector.createInternal (/AppModule/module.ngfactory.js:346:36) [angular]
at AppModuleInjector.NgModuleInjector.create (http://localhost:5000/dist/vendor.js?v=zXjAceTbWZzNTMXFaXt8RHn0kEuzf0rVAtRzIJqw-9Q:79287:76) [angular]
at NgModuleFactory.create (http://localhost:5000/dist/vendor.js?v=zXjAceTbWZzNTMXFaXt8RHn0kEuzf0rVAtRzIJqw-9Q:79255:18) [angular]
(anonymous) @ main-client.js:1917
SafeSubscriber.__tryOrUnsub @ vendor.js:21253
SafeSubscriber.complete @ vendor.js:21238
Subscriber._complete @ vendor.js:21151
Subscriber.complete @ vendor.js:21133
Subscriber._complete @ vendor.js:21151
Subscriber.complete @ vendor.js:21133
onLoad @ vendor.js:81460
ZoneDelegate.invokeTask @ vendor.js:66774
onInvokeTask @ vendor.js:44878
ZoneDelegate.invokeTask @ vendor.js:66773
Zone.runTask @ vendor.js:66573
ZoneTask.invoke @ vendor.js:66827

Having the same issue here. When I added console.log(fileName) in createSourceFile(), it seems the problem file is:
<EMAIL_ADDRESS>Any idea how to fix this, or work around it?

I found two issues in my project:

I had references in my src/typings/tsd.d.ts file that were trying to reference Angular's index.d.ts (and other files) from the wrong location.

I needed to move my main.ts file from src/app/main.ts to src/main.ts

It would have been quite helpful if, in addition to seeing what file causes the error (can't be found), were were also told WHAT PARENT referenced this missing file. THAT would be helpful.

well that's great, that's just great man, now what am i suppose to do.. that's it man, game over man, game over..

delete node_modules and npm install is ok for me

This make some sense for somebody ?
I put a log info like that in line 14875:
console.log('sourceText content:' + fileName + ' sourcetext:' + sourceText);
result ==>  sourceText content:/Users/Felipe/workspaces/workspace IntelliJ14/static.montafesta.com/test.ts sourcetext:undefined
=== my tests.js
// This file is required by karma.conf.js and loads recursively all the .spec and framework files
import 'zone.js/dist/long-stack-trace-zone';
import 'zone.js/dist/proxy.js';
import 'zone.js/dist/sync-test';
import 'zone.js/dist/jasmine-patch';
import 'zone.js/dist/async-test';
import 'zone.js/dist/fake-async-test';
import { getTestBed } from '@angular/core/testing';
import {
BrowserDynamicTestingModule,
platformBrowserDynamicTesting
} from '@angular/platform-browser-dynamic/testing';
// Unfortunately there's no typing for the __karma__ variable. Just declare it as any.
declare var karma: any;
declare var require: any;
// Prevent Karma from running prematurely.
karma.loaded = function () {};
// First, initialize the Angular testing environment.
getTestBed().initTestEnvironment(
BrowserDynamicTestingModule,
platformBrowserDynamicTesting()
);
// Then we find all the tests.
const context = require.context('./', true, /.spec.ts$/);
// And load the modules.
context.keys().map(context);
// Finally, start Karma to run the tests.
karma.start();

I found the problem of my case:
I change the location of tsconfig.spec.json and tsconfig.app.json up to src folder.
So when i put a console.log debug line in typescript.js line ~14877, i realized the error was in tests.js file!
So the reason was the path in tsconfig's of  files tag
"files" : [ "test.js" ] was wrong, because location changes.
So i fixed than, to
"files" : [ "src/test.js" ]  !
This this can be the reason the this problem, for others persons.
The karma start works fine now.
======================== My second case, when i  ng serve, i receive the error below.
Cannot read property 'length' of undefined
TypeError: Cannot read property 'length' of undefined
at createSourceFile (/Users/Felipe/workspaces/workspaces/myproject/node_modules/typescript/lib/typescript.js:14877:109)
and the debug fileName - "<EMAIL_ADDRESS>s"
the path has the wrong root to the angular-datatable!
So i did get resolve this point.

I've received this error when a generated (and referenced) d.ts file was missing. If you receive the error the issue is probably in you project..
/// <reference path="../../someFileThatDidntExist.d.ts" />

thank you for clarifications CanKattwinkel,  The question is: Why earlier versions of @angular/cli does not happen ?
Why should i do,  ignore in the exclude tag of tsconfig, some important dependency modules?
Some suggestion?

FWIW in my case this error tripped after a large refactor / rename exercise. It went away after I restarted ng serve.

I stopped ng serve and restarted it, now the error message is gone.

I also had issues with my build. The issue was with the environment files in my angular-cli.json as pointed by @moosetraveller and some others.
Thank you all for big help!

I had the same error. My problem was that the "test.ts" under the "src" folder was missing for some reason.  Restored the file from a backup and it is working fine now.  The karma.conf.js has a reference to that file as... { pattern: './src/test.ts', watched: false }
Thanks for everyone for pointing me in the right direction.

Have the same issue.
After running ng test: 11 tests passed & 1 failed. Here is output:
Chrome 58.0.3029 (Windows 10 0.0.0) PasswordMeterComponent should create FAILED
TypeError: Cannot read property 'length' of undefined
at Object.eval [as updateDirectives] (ng:///DynamicTestModule/PasswordMeterComponent.ngfactory.js:101:40)
at Object.debugUpdateDirectives [as updateDirectives] (webpack:///~/@angular/core/@angular/core.es5.js:12806:0 <-
src/test.ts:13113:21)
at checkAndUpdateView (webpack:///~/@angular/core/@angular/core.es5.js:12144:0 <- src/test.ts:12451:14)
at callViewAction (webpack:///~/@angular/core/@angular/core.es5.js:12507:0 <- src/test.ts:12814:21)
at execComponentViewsAction (webpack:///~/@angular/core/@angular/core.es5.js:12439:0 <- src/test.ts:12746:13)
at checkAndUpdateView (webpack:///~/@angular/core/@angular/core.es5.js:12150:0 <- src/test.ts:12457:5)
at callWithDebugContext (webpack:///~/@angular/core/@angular/core.es5.js:13206:25 <- src/test.ts:13513:42)
at Object.debugCheckAndUpdateView [as checkAndUpdateView] (webpack:///~/@angular/core/@angular/core.es5.js:12746:0
<- src/test.ts:13053:12)
at ViewRef_.Array.concat.ViewRef_.detectChanges (webpack:///~/@angular/core/@angular/core.es5.js:10218:52 <- src/t
est.ts:10525:63)
at ComponentFixture.Array.concat.ComponentFixture._tick (webpack:///~/@angular/core/@angular/core/testing.es5.js:1
82:0 <- src/test.ts:18857:32)
Chrome 58.0.3029 (Windows 10 0.0.0): Executed 1 of 12 (1 FAILED) (skipped 11) ERROR (0.356 secs / 0.137 secs).
Have read this topic. All the files in places. ng serve works normally. So only 1 problem with 1 unit test. Here is the file:
import { async, ComponentFixture, TestBed } from '@angular/core/testing';
import { PasswordMeterComponent } from './password-meter.component';
fdescribe('PasswordMeterComponent', () => {
let component: PasswordMeterComponent;
let fixture: ComponentFixture;
beforeEach(async(() => {
TestBed.configureTestingModule({
declarations: [ PasswordMeterComponent ]
})
.compileComponents();
}));
beforeEach(() => {
fixture = TestBed.createComponent(PasswordMeterComponent);
component = fixture.componentInstance;
fixture.detectChanges();
});
it('should create', () => {
expect(component).toBeTruthy();
});
});
Any ideas?

I noticed that in a project created (that does not get this error) with ng new (@angular/cli 1.0.6) that the angular-cli.json file was renamed to .angular-cli.json (hidden file).
I renamed the file in my upgrading project but did not help. I mention this because there must be something else that has changed that may be causing the issue.
Although, this does seem like a code incompatibility issue - probably some dependency that is out of sync. But it is not obvious. I brought versions in package.json to the same levels.

How to fix it?

For what it's worth, I got this error when referencing a d.ts file via: ///<reference path="./foo.d.ts" /> with an invalid path, which I discovered using @klferreira's suggestion, on #5132:

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.

This error seem to have different reasons and different solutions. In my case I had a reference /// pointing to a file that did not exist.

This happened to me, somehow my 'typings' folder was missing, I just restored it and everything worked fine.

@leandrolanzieri Thanks for the suggestion. This was the problem for me. Was banging my head against the wall for a while.

I hit this error when I started trying to work on a clean machine and cloned our repo.
Currently we have an environment.prod.ts & an environment.ts file referenced in our .angular-cli.json, however, it's up to the deb to create a local environment.ts and it's configured to be gitignored.
I forgot to create a local environment.ts and banged my head against this error for 45mins until I remembered to create one.
Like most other people on this thread I would have appreciated a pretty error message telling me that (in my case) "An environment.ts file was specified in .angular-cli.json but could not be found at this "

I had the same issue. In my case, it was a typo in the environment settings in angular-cli,json. Make sure it spelled correctly like this environments/environment.xyz.ts.

I had the same issue. In my case, I had to remove some sub-folders under the 'typings' folder, which I forgot to also remove from the index.d.ts file. Hope this helps someone.

Guys any update on this issue ?

I have some problem in a fwe moments ago...
I shell ng serve -e local
And i check my .angular-cli.json file and not found  "local": "environments/environment.local.ts"
Before i check this, problem is solved
Try this x)
P.S. Sorry for my bad english

I just had the same issue, and got to resolve it by changing the path to the enviroments folder in my .angular-cli.json. From this:
"environmentSource": "environments/environment.ts",
"environments": {
    "dev": "environments/environment.ts",
    "prod": "environments/environment.prod.ts"
}

To this:
"environmentSource": "src/environments/environment.ts",
"environments": {
    "dev": "src/environments/environment.ts",
    "prod": "src/environments/environment.prod.ts"
}

Be sure that you've the reference to the files right.

FYI - I also get this issue when referencing an invalid d.ts file. Confirmed on 1.3.0-rc.5 (which I am stuck on due to another bug)

select: function () {
var self = this;
self.$http.post("/purchase/rfq-table", {
"username": self.options,
}).then(function(res){
var data = res.body.result;
self.tabledata = [];
if(data.length > 0){
data.forEach(function(val) {
self.tabledata.push({
"data": [
val.name,
val.schedule_date,
],
"url": "/purchase/RQ/"+val.id,
});
});
console.log(self.tabledata);
}
//self.options =res.body.data;
},function(err){
alert(err);
});
},

Uncaught (in promise) TypeError: Cannot read property 'length' of undefined
i dont know the error please help me out this.

@unsama simply do:
if(data && data.length > 0)

@istiti thanks

Adding missing environment file fixed this form me.

Just a comment to help those that find this page when getting the issue.
If I rename or move files while in VS Code and ng serve is running, I get the error. Closing/Opening VS Code fixes the issue.

I had this issue when i deleted a file and forgot to recall an ng serve .

I fixed this issue by making sure the names in .angular-cli.json for environment files were pointing to the right place.
Eg. I had:
    "environmentSource": "environments/environment.ts",
      "environments": {
        "dev": "environments/environment.ts",
        "devServer": "environments/environment.dev.ts",
        "prod": "environments/environment.prod.ts"
      }

and should have had:
    "environmentSource": "src/environments/environment.ts",
      "environments": {
        "dev": "src/environments/environment.ts",
        "devServer": "src/environments/environment.dev.ts",
        "prod": "src/environments/environment.prod.ts"
      }

It was erroring on finding the right file (as described in adding the log statement to the typescript source above), but it was pointing at the correct file name, which was odd.

Even i came across with this issue but got it resolved by doing ng build

this issue isn't  solved ? i forget i opened it on february but now i got one more time this error and can't go ahead , donno how this happends but now  cant run ng s or ng b BUT ng -v works and ng g c ok works too
here's my json config cli file https://gist.github.com/istiti/48b4ab21c90ceb529972f8d917bdf8d4

@simonv3 : That was my problem too. Thx

Adding missing environment folder also fixed this problem for me.

Please I'm having the same error and i have been trying to resolve the issue for he past 3 days now with any solution.
Node version v8.8.1
npm version 5.4.2
Here is the error message i get
TypeError: Cannot read property 'length' of undefined
at createSourceFile (E:\web\bsv.app\ng4\node_modules\typescript\lib\typescript.js:16551:110)
at parseSourceFileWorker (E:\web\bsv.app\ng4\node_modules\typescript\lib\typescript.js:16483:26)
at Object.parseSourceFile (E:\web\bsv.app\ng4\node_modules\typescript\lib\typescript.js:16432:26)
at Object.createSourceFile (E:\web\bsv.app\ng4\node_modules\typescript\lib\typescript.js:16282:29)
at new TypeScriptFileRefactor (E:\web\bsv.app\ng4\node_modules@angular\cli\node_modules@ngtools\webpack\src\refactor.js:34:35)
at Object.resolveEntryModuleFromMain (E:\web\bsv.app\ng4\node_modules@angular\cli\node_modules@ngtools\webpack\src\entry_resolver.js:105:20)
at AotPlugin._setupOptions (E:\web\bsv.app\ng4\node_modules@angular\cli\node_modules@ngtools\webpack\src\plugin.js:152:50)
at new AotPlugin (E:\web\bsv.app\ng4\node_modules@angular\cli\node_modules@ngtools\webpack\src\plugin.js:27:14)
at _createAotPlugin (E:\web\bsv.app\ng4\node_modules@angular\cli\models\webpack-configs\typescript.js:55:12)
at Object.exports.getNonAotConfig (E:\web\bsv.app\ng4\node_modules@angular\cli\models\webpack-configs\typescript.js:71:19)
at NgCliWebpackConfig.buildConfig (E:\web\bsv.app\ng4\node_modules@angular\cli\models\webpack-config.js:29:37)
at Class.run (E:\web\bsv.app\ng4\node_modules@angular\cli\tasks\serve.js:43:98)
at check_port_1.checkPort.then.port (E:\web\bsv.app\ng4\node_modules@angular\cli\commands\serve.js:114:26)
at
at process._tickCallback (internal/process/next_tick.js:188:7)
package.json file
{
"name": "name",
"version": "1.0.0",
"license": "MIT",
"scripts": {
"ng": "ng",
"start": "ng serve",
"build": "ng build",
"test": "ng test",
"lint": "ng lint",
"e2e": "ng e2e"
},
"private": true,
"dependencies": {
"@agm/core": "1.0.0-beta.0",
"@angular/animations": "4.3.2",
"@angular/cdk": "2.0.0-beta.8",
"@angular/common": "4.3.2",
"@angular/compiler": "4.3.2",
"@angular/core": "4.3.2",
"@angular/flex-layout": "2.0.0-beta.8",
"@angular/forms": "4.3.2",
"@angular/http": "4.3.2",
"@angular/material": "2.0.0-beta.8",
"@angular/platform-browser": "4.3.2",
"@angular/platform-browser-dynamic": "4.3.2",
"@angular/router": "4.3.2",
"@angular/service-worker": "^1.0.0-beta.16",
"@ng-bootstrap/ng-bootstrap": "^1.0.0-beta.5",
"@swimlane/ngx-datatable": "9.3.0",
"@types/file-saver": "0.0.1",
"angular-calendar": "0.17.0",
"angular-sortablejs": "^2.0.6",
"angular-tree-component": "3.8.0",
"angular2-jwt": "^0.2.3",
"angular2-moment": "^1.7.0",
"angular2-recaptcha": "^0.6.0",
"angular4-paystack": "^1.2.1",
"chart.js": "2.6.0",
"ckeditor": "4.6.0",
"core-js": "2.4.1",
"css-element-queries": "^0.4.0",
"d3": "^3.5.17",
"dragula": "3.7.2",
"easy-pie-chart": "2.1.7",
"file-saver": "^1.3.3",
"font-awesome": "4.7.0",
"hammerjs": "2.0.8",
"jquery": "2.2.4",
"leaflet": "^1.0.2",
"leaflet-map": "0.2.1",
"material-datetime-picker": "^2.4.0",
"moment": "^2.15.0",
"ng2-breadcrumb": "0.5.6",
"ng2-charts": "1.6.0",
"ng2-ckeditor": "1.1.8",
"ng2-device-detector": "^1.0.0",
"ng2-dragula": "1.3.1",
"ng2-file-upload": "1.2.1",
"ng2-file-uploader": "^0.1.4",
"ng2-translate": "5.0.0",
"ng2-validation": "4.2.0",
"ng2modules-easypiechart": "^0.0.4",
"ng4-social-login": "^1.3.3",
"ngx-color-picker": "^4.4.0",
"ngx-perfect-scrollbar": "^2.0.1",
"ngx-quill": "^1.5.1",
"normalize.css": "^5.0.0",
"nvd3": "^1.8.5",
"quill": "^1.2.6",
"rxjs": "5.4.2",
"screenfull": "^3.3.2",
"sortablejs": "^1.6.1",
"ts-helpers": "^1.1.2",
"zone.js": "0.8.16"
},
"devDependencies": {
"@angular/cli": "1.3.2",
"@angular/compiler-cli": "4.3.2",
"@types/d3": "^3.5.17",
"@types/jasmine": "2.5.52",
"@types/jquery": "3.2.0",
"@types/node": "7.0.8",
"@types/nvd3": "^1.8.33",
"codelyzer": "3.0.1",
"html-webpack-plugin": "^2.30.1",
"jasmine-core": "2.6.3",
"jasmine-spec-reporter": "4.1.0",
"karma": "1.7.0",
"karma-chrome-launcher": "2.1.1",
"karma-cli": "1.0.1",
"karma-coverage-istanbul-reporter": "1.3.0",
"karma-jasmine": "1.1.0",
"karma-jasmine-html-reporter": "0.2.2",
"protractor": "5.1.2",
"ts-node": "3.0.6",
"tslint": "5.4.3",
"typescript": "2.4.0",
"webpack": "^3.8.1",
"webpack-dev-server": "^2.9.4"
}
}
.angular-cli.json file
{
"$schema"<EMAIL_ADDRESS>"project": {
"version": "1.0.0",
"name": "BulkSMSVilla"
},
"apps": [
{
"root": "src",
"outDir": "dist",
"assets": [
"assets"
],
"index": "index.html",
"main": "app/main.ts",
"polyfills": "polyfills.ts",
"test": "test.ts",
"tsconfig": "tsconfig.app.json",
"testTsconfig": "tsconfig.spec.json",
"prefix": "ms",
"styles": [
"assets/scss/style.scss",
"../node_modules/quill/dist/quill.snow.css",
"../node_modules/leaflet/dist/leaflet.css",
"../node_modules/angular-calendar/dist/css/angular-calendar.css",
<EMAIL_ADDRESS><EMAIL_ADDRESS>"../node_modules/nvd3/build/nv.d3.css",
"../node_modules/font-awesome/scss/font-awesome.scss",
"assets/fonts/data-table/icons.css",
"../node_modules/dragula/dist/dragula.css"
],
"scripts": [
"../node_modules/jquery/dist/jquery.min.js",
"../node_modules/hammerjs/hammer.js",
"../node_modules/sortablejs/Sortable.js",
"../node_modules/chart.js/dist/Chart.bundle.min.js",
"../node_modules/easy-pie-chart/dist/easypiechart.js"
],
"environmentSource": "environments/environment.ts",
"environments": {
"dev": "environments/environment.ts",
"prod": "environments/environment.prod.ts"
}
}
],
"e2e": {
"protractor": {
"config": "./protractor.conf.js"
}
},
"lint": [
{
"project": "src/tsconfig.app.json"
},
{
"project": "src/tsconfig.spec.json"
},
{
"project": "e2e/tsconfig.e2e.json"
}
],
"test": {
"karma": {
"config": "./karma.conf.js"
}
},
"defaults": {
"styleExt": "scss",
"component": {}
}
}
Please help.

@kelvinrolex Most people are seeing this error when there is a filepath configured in the .angular-cli.json that the cli can't find in your project directory. Quite often it appears to be a missing environment.ts but It's going to be a case of checking each file in turn and making sure the filepath is correct.

Thanks so much @simonneedham, problem solved, in my own case, i compared the .angular-cli.json file with an old backup i did and i noticed the "main": "app/main.ts", line is having app so i removed the app and ng serve and it started working again.

npm update will help you...

@kelvinrolex Cool,. I think that instead of barfing with 'Cannot read property 'length' of undefined' the CLI should be throwing an error telling you which filepath/file it couldn't find in .angular-cli.json.

@simonneedham yeah, the CLI wasn't specific at all, I spent 3 days battling with that error without any success until you said I should look into .angular-cli.json. Thanks once more.

same issue here, I upgraded a library (Msal JS) in a branch, then reverted back to master, without running yarn. The tip to add a console.log in typescript.js was brilliant!

I get same problem when I run "ng build --aot"  but I don't wait it finish ,just type "ctrl + c" stop it
I fix this issue when I delete my project and checkout from my svn place and run "npm i"

Having the same issue when I try to run cordova build android or cordova run android.
I have tried all solution reported here but none worked.
...\trunk\src\platforms\android\assets\www\main.bundle.js Error: Cannot read property 'length' of null

Everyone look at the lines below this one:
https://github.com/angular/angular-cli/blob/4b0c7a35359effc1d93cd3bb5ddc5c441b3cf154/packages/%40ngtools/webpack/src/angular_compiler_plugin.ts#L157
That basePath variable is not used anywhere, and the actual config basePath gets reset to the current directory anyway... and later on in the execution, namely here: https://github.com/angular/angular-cli/blob/4b0c7a35359effc1d93cd3bb5ddc5c441b3cf154/packages/%40ngtools/webpack/src/refactor.ts#L107 source || _host.readFile(fileName) is undefined.
So basically if you move the files you wanna compile somewhere outside you get this.
Can someone explain this nonsense code here?

the filename passed to createSourceFile function has wrong name ,
Its taking adventureimage.ts but actually it is AdventureImage.ts (capital A and I), Renaming the file name to all small solves the problem.

this is very weird, but i got it working similar to the above. You just need to make sure every array and key has been filled with a value that exists, even when you might not use that key.
    {
      "name": "core",
      "root": "core",
      "outDir": "dist",
      "assets": [],
      "index": "../src/index.html",
      "main": "../src/main.ts",
      "polyfills": "../src/polyfills.ts",
      "test": "../src/test.ts",
      "tsconfig": "../src/tsconfig.app.json",
      "testTsconfig": "../src/tsconfig.spec.json",
      "prefix": "core",
      "styles": [],
      "scripts": [],
      "environmentSource": "../src/environments/environment.ts"
    }

i suspect this length issue may be caused by File path too long on windows, keep below 240 characters, which is mostly encountered on Windows OS.

in @ngtools/webpack it says you can configure basePath but in the process it ends up here
https://github.com/angular/angular/blob/c2b3792a3b5fa5215fe2ef7e0ac6511086ffe4c1/packages/compiler-cli/src/perform_compile.ts#L116
and it is all messed up to be honest!

This appears to be a discrepancy issue with custom environment files / paths.
running : "hmr": "ng serve --hmr --env=hmr" produces
ERROR in TypeError: Cannot read property 'length' of undefined
Logging filename & sourceText in function createSourceFile outputs:
filename: environment.ts (<--- should this not be environment.hmr.ts ?)
sourceText: undefined
WARNING: to anyone using @simonv3 solution above (adding src/...). Although it does work, it will also BREAK the environment on build (always using the development env)
running "start": "ng serve" seems to work without issue however.

So what is the final solution to this error? Can someone post step by step measures for those who are facing this issue but would probably not want to read through the entire thread?

@cyberbeast In summary, the issue is caused by a misconfigured entry in a project's .angualr-cli.json file. It's usually an incorrect file path, so either a file has disappeared/moved/wasn't-checked-in-and-so-isn't-present-on-a-different-dev-machine or the .angualr-cli.json was just edited incorrectly.
If you hit this issue you just have to work through each file referenced and make sure it exists. This can be a little tricky as the paths are relative. You could consider removing non-essential lines to get a working build and then add paths back one by one till you find the path that doesn't work.
I think the proper resolution should be that the CLI should tell you what file it couldn't find, and the absolute path where it expected the file to be, instead of throwing a cannot read property 'length' of undefined message at you.

The root cause is a poor error message in the TypeScript system. Therefore the solution would be a patch to TypeScript that improves the error message to tell the user WHICH file is missing from .angular-cli.json. Also angular.io should say something about this! They paint such a rosy picture when selling Angular.

For me it was missing environment files. Adding them fix the issue

I think I'm panicking.
ERROR TypeError: Cannot read property 'length' of undefined     at eval (http.js:123)     at Array.forEach (<anonymous>)     at HttpHeaders.lazyInit (http.js:117)     at HttpHeaders.init (http.js:265)     at HttpHeaders.forEach (http.js:368)     at Observable.eval [as _subscribe] (http.js:2172)     at Observable._trySubscribe (Observable.js:172)     at Observable.subscribe (Observable.js:160)     at subscribeToResult (subscribeToResult.js:23)     at MergeMapSubscriber._innerSub (mergeMap.js:138)
And it's not because I was missing the environment files declaration.

I had the same issue, for me it was caused by the following code:
 if(!(Object.prototype.defineProperty instanceof Function)
      && Object.prototype.__defineGetter__ instanceof Function
      && Object.prototype.__defineSetter__ instanceof Function)
   {
      Object.defineProperty = function(obj, p, cfg) {
         if(cfg.get instanceof Function)
            obj.__defineGetter__(p, cfg.get);
         if(cfg.set instanceof Function)
            obj.__defineSetter__(p, cfg.set);
      }
   }

Commenting the above out fixed it for me.
Still a library i'm using (Box2D) has this implemented, anyone any idea on how to fix this?

Same with me-- error on unit test re-build. Downgrading works.

Same here.

I followed the instruction to put a console.log() call in typescript.js. Funnily, my angular project fails when it tries to read:
Trying to read file: /home/js/myproject/src

Obviously, this isn't a source file - it's a directory where my sources are kept, but for some reason ng cli tries to read it like it was a file and fails miserably. Any ideas what might be wrong in this case?

Can confirm that downgrading to 1.6.1 worked from 1.6.7. But one of my developers has it working fine with 1.6.5 which did not work for me. So unsure of what is actually going on.

Also had a environments error in my angular.json (thanks to @RichyRoo5by5 and others for pointing me in the right direction). I had renamed my environments file but didn't update my angular-cli.json file.

In my case i discovered that my environments.dev.ts file was missing, all of a sudden. Restored it from git and now this problem disappeared.

I have the same issue (more accurately described in 9558 since it has to do with re-loads, the test runner works fine on the first ng test). I downgraded the CLI temporarily to 1.6.1 but in doing so, I had to install @angular-devkit/core as a dev dependency (yarn add --dev @angular-devkit/core) as well to get it to compile.

This may also happen, when you have defined an environment-file in .angular-cli.json but the environment.ts file it self doesn't exist.

This will also happen regardless the angular versions when you define an environment file in your .angular-cli.json but the environment file itself doesn't exist.

I think I have narrowed down the cause of this error. My environment files etc all appear to match those of a new ng5 app so that wasn't my issue. This line in the @ngtools/webpack plugin is why my tests fail on the second run:
https://github.com/angular/angular-cli/blob/master/packages/%40ngtools/webpack/src/plugin.ts#L622-L624
this._discoveredLazyRoutes = this.firstRun
    ? this._getLazyRoutesFromNgtools()
    : this._findLazyRoutesInAst();

It looks like there is a bug in _findLazyRoutesInAst() that only affects ng4 apps.
this._getLazyRoutesFromNgtools() Works fine and is used on the first pass.
this._findLazyRoutesInAst(); Is used on the second pass and always results in an eventual length of undefined error.
I am going to debug a little more and see what each function returns. For now, locally, replacing that ternary statement with this._discoveredLazyRoutes = this._getLazyRoutesFromNgtools(); allows me to run my tests normally.

I am actually able to run ng serve and ng test normally, the watcher works well for ng serve, but I got this error when I update any file while I am on ng test, after looking at the comments, I made sure I have environment.ts and no issues on my tests.ts (even rolling back to previous versions). Doing what @mhamel06 worked well, but I was wondering if there is something else that we can check on our end just to fix the watcher loop on ng test mode, any thoughts on karma.conf and webpack conf maybe just to avoid this?.

Thanks @FunnyGhost, I just downgraded cli version and it worked to me.

+1 for me
Same as @mhamel06 - seems to be something with  the _findLazyRoutesInAst() call...

+1 we have the same problem

I was with the same problema. After 'googling", my issue was resolved by running this:

npm install<EMAIL_ADDRESS><2.4.0'

(after run "ng serve", console displayed "run the following command to install a compatible version of TypeScript.";

After step 1, console displayed:

npm WARN<EMAIL_ADDRESS>requires a peer of<EMAIL_ADDRESS>but none is installed. You must install peer dependencies yourself.
npm WARN<EMAIL_ADDRESS>requires a peer of<EMAIL_ADDRESS>but none is installed. You must install peer dependencies yourself.

So, i run:

npm install<EMAIL_ADDRESS>

npm install<EMAIL_ADDRESS>

After that, all is right!
I hope i have helped!
package.zip

In my case, it's the same what @samupl has reported. A directory is passed to to TypeScripts' createSourceFile method by TypeScriptFileRefactor constructor.
I've bumped into this issue when I've implemented dynamic stories loading in Storybook. By using require.context to search for files in a specific directory webpack starts watching the directory alongside the files and this directory is passed to createSourceFile when a change happens.
I'm not sure who is to blame for not skipping directories in the course of events leading to createSourceFile call.

@nikdo it might be fixable on our side, but so far I don't think I've seen a repro that I follow so it's hard to debug and try fixes :/

Thank you for a quick reply, @filipesilva.
After few hours of debugging, I think the problem was introduced by setting a filename to CompilerHost._changedFiles even if the filename is not present in CompilerHost._files array introduced in commit to avoid caching binary resources as UTF8.
That way when a directory is passed to CompilerHost.invalidate method it is handled as a file causing issue mentioned above.
What was the motivation for the change? It seems unrelated to other changes introduced in that commit.

@nikdo I'm not too sure really. If I had to bet, it was to ensure new files would be picked up on reload. Do you have a repro we can follow to see this?

In my case, bower was configured to install bower dependencies at src/assets/bower_components, so had to exclude bower_components from auto type acquisition, as the typescript compilation was looking for typescript declarations (*.d.ts) for those files, and it wasn't finding them.
In tsconfig.app.json, I excluded assets/bower_components/**/*.*
{
  "extends": "../tsconfig.json",
  "compilerOptions": {
    "outDir": "../out-tsc/app",
    "module": "es2015",
    "baseUrl": "",
    "types": []
  },
  "exclude": [
    "test.ts",
    "**/*.spec.ts",
    "assets/bower_components/**/*.*"
  ]
}

The above comment by @calebkiage helped me in identifying this issue

Just 4 Info, i had same Problem and i went almost crazy...
Cannot read property 'length' of undefined TypeError: Cannot read property 'length' of undefined     at createSourceFile (C:\DEV\AFB\varias-bepro\bepro-frontend\src\main\frontend\node_modules\typescript\lib\typescrip t.js:14652:110)
But you know what the problem was?
at the beginning of  one of my .ts file was a line like this:
///<reference path="../../../generated/rest/model/Template.ts"/> import {Component, OnDestroy, OnInit} from '@angular/core'; import {FormGroup} from '@angular/forms';
This caused the error! Without any hint. Nothing. I thought my enviroment is broken, some wrong version or something like that.
I removed the line and it worked. But i still don't know how the line got there in the first place...
I hope it helps somebody.

It seems to be an issiue of file/files cannot find in app.  I spent some 2-3 hours but resolved with including environments directory to project after pc format, re-install from repo etc.

@lychyi 's comment worked for me. Hope this issue is resolved soon.

Thanks for pointing me in the right direction @tmrdurgun . I'm currently in a nrwl project and was adding an environment file path to the wrong app object config.

Had the same issue, turned out that in node_modules/typescript/lib/typescript.js (line 12619) the sourceText variable was undefined somehow (function code below) . It pointed to the src/environments/environment.ts file (that existed) while the .angular-cli.json dev environment pointed to environments/environment.dev.ts (that existed too). (ng serve --env=dev was executed)
Setting the .angular-cli.json dev environment to environments/environment.ts solved the problem for now.
package.json:
...
"devDependencies": {
		"@angular/cli": "~1.7.2",
		"@angular/compiler-cli": "^5.2.0",
		"@angular/language-service": "^5.2.0",
		"@types/jasmine": "~2.8.3",
		"@types/jasminewd2": "~2.0.2",
		"jasmine-core": "~2.8.0",
		"jasmine-spec-reporter": "~4.2.1",
		"karma": "~2.0.0",
		"karma-chrome-launcher": "~2.2.0",
		"karma-coverage-istanbul-reporter": "^1.2.1",
		"karma-jasmine": "~1.1.0",
		"karma-jasmine-html-reporter": "^0.2.2",
		"protractor": "~5.1.2",
		"typescript": "~2.5.3"
	}

function createSourceFile(fileName, languageVersion, scriptKind) {
            // code from createNode is inlined here so createNode won't have to deal with special case of creating source files
            // this is quite rare comparing to other nodes and createNode should be as fast as possible
            var sourceFile = new SourceFileConstructor(265 /* SourceFile */, /*pos*/ 0, /* end */ sourceText.length);
            nodeCount++;
            sourceFile.text = sourceText;
            sourceFile.bindDiagnostics = [];`
            ...
}

I ran into this error, finally, I found out it was because a typo inside string interpolation. I wrote {{ string**!** }} instead of {{ string }}.

Simply delete a component folder and the angular-cli will detect the change and try to recompile. The code seems to link to a createSourceFile function in typescript.js
var sourceFile = new SourceFileConstructor(265 /* SourceFile */, /*pos*/ 0, /* end */ sourceText.length);

I assume typescript is getting passed a file that doesn't exist anymore and fails to create it?

There might be an issue with environment.ts file.
check if it is really-
export const environment = {
production: false,
dialogflow: {
angularBot: 'YOUR_CLIENT_TOKEN'
}
};

I did this change and it worked for me.

@filipesilva Can confirm what @nikdo said, and we fixed by downgrading cli to 1.6.1. I can get some time early next week to debug a little or see if our package.json yields a repro. Mention me if that would help.

https://github.com/angular/devkit/pull/667 should fix this in 6.0 by failing early when the specified environment file (it will be called fileReplacements in v6) does not exist.

Marking this nice to have because there seems to be a fix already.

I created this patch for version 1.7.3 , you can apply the patch to<EMAIL_ADDRESS>and you should be good to go.
493c492,494
<             this._discoveredLazyRoutes = this._getLazyRoutesFromNgtools();
---
>             this._discoveredLazyRoutes = this.firstRun
>                 ? this._getLazyRoutesFromNgtools()
>                 : this._findLazyRoutesInAst();

To me removing comments from the environments  files worked :+1:  :1234:

I too like others found the problem to be with the "plugin.js" file within<EMAIL_ADDRESS>The problem is with the "_findLazyRoutesInAst()" function. This function is called on the second pass when running your unit test (w/ Karma). This function only looks at files that have been modified, and there is a file path in the array "this._compilerHost.getChangedFilePaths()" that ends with "/src", and all of the other paths end with .ts files. To resolve this problem, I check the file path to see if it ends with ".ts", and if so, I push that path into an array. Below is my solution to this problem. I would like to submit this as a bug fix, but I do not know where to do so.
------- plugin.js : ln 211 -------
_findLazyRoutesInAst() {
benchmark_1.time('AotPlugin._findLazyRoutesInAst');
const result = Object.create(null);
var changedFilePaths = [];
this._compilerHost.getChangedFilePaths().forEach(f => {
if(f.endsWith(".ts")) {
changedFilePaths.push(f);
}
});
for (const filePath of changedFilePaths) {
const fileLazyRoutes = lazy_routes_1.findLazyRoutes(filePath, this._compilerHost, this._program);

I have modified this file and it works fine, but it will never be fixed in any new version?
This is my solution, it's similar to @ atariman5000 but inside an for:
_findLazyRoutesInAst() {
  benchmark_1.time('AotPlugin._findLazyRoutesInAst');`
  const result = Object.create(null);`
  const changedFilePaths = this._compilerHost.getChangedFilePaths();`

  for (const filePath of changedFilePaths) {
 >> if(filePath.match(/.*\/*\.[A-Za-z]*$/)) {
      const fileLazyRoutes = lazy_routes_1.findLazyRoutes(filePath, this._compilerHost, this._program);
      for (const routeKey of Object.keys(fileLazyRoutes)) {
        const route = fileLazyRoutes[routeKey];
        if (routeKey in this._lazyRoutes) {
          if (route === null) {
             this._lazyRoutes[routeKey] = null;
          }
          else if (this._lazyRoutes[routeKey] !== route) {
             this._compilation.warnings.push(new Error(`Duplicated path in loadChildren detected during a rebuild. `
                    + `We will take the latest version detected and override it to save rebuild time. `
                    + `You should perform a full build to validate that your routes don't overlap.`));
           }
         }
         else {
            result[routeKey] = route;
         }
      }
    }
  }
  benchmark_1.timeEnd('AotPlugin._findLazyRoutesInAst');
  return result;
}

I had a similar message recently when I added some new environments files in the angular-cli.json
        "prod": "environments/environment.prod.ts",
        "xamp": "environments/environment.xamp..ts"

The problem was I misstyped the name of one of the files: environment.xamp**.**.ts (I typed twice the dot)
I was very hard to figure what was wrong with my project (Only I Know it had to be something with the environments files). A nice error sugesting about how i misspelled the files would have been perfect :/

This error should be improved.. for instance.. in most of the cases is the environment.xxx.ts missing.. so a message where file could not be found would be nice!

My team has been struggling with this for months, but @mhamel06's comment resolved the issue for me. It would be nice to have an actual fix that doesn't require modification of a lib file though.

The variant of the problem described by @FunnyGhost in https://github.com/angular/angular-cli/issues/5053#issuecomment-355977860 is gone in 6.0.7.


Fiscal updates

This PR will make some updates to how fiscal related variables are computed in OG-USA.  The following changes will be made:

Fix an indexing error in the calculation of foreign debt holdings, D_f.
Move the lines of code to determine the path of foreign and domestic debt holdings into the fiscal.get_D_G_path() function.
Create a function to compute transfers within fiscal.py (this and the above help to remove conditional statements related to the balanced budget option from the main TPI (and SS) code.
Allow non-zero government spending in the balanced budget configuration.

Codecov Report

Merging #563 into master will increase coverage by 4.16%.
The diff coverage is 93.03%.

@@            Coverage Diff             @@
##           master     #563      +/-   ##
==========================================
+ Coverage   80.24%   84.40%   +4.16%
==========================================
  Files          47       47
  Lines        6500     6600     +100
==========================================
+ Hits         5216     5571     +355
+ Misses       1284     1029     -255

Impacted Files
Coverage Δ

ogusa/constants.py
100.00% <ø> (ø)

ogusa/tests/test_basic.py
33.33% <8.33%> (-7.70%)
:arrow_down:

ogusa/tests/test_startyears.py
50.00% <50.00%> (ø)

ogusa/SS.py
88.66% <84.21%> (+14.88%)
:arrow_up:

ogusa/TPI.py
77.67% <94.28%> (+55.96%)
:arrow_up:

ogusa/tests/test_TPI.py
67.52% <95.45%> (+8.19%)
:arrow_up:

ogusa/tests/test_SS.py
95.93% <95.65%> (-0.36%)
:arrow_down:

ogusa/aggregates.py
96.03% <100.00%> (+0.26%)
:arrow_up:

ogusa/fiscal.py
100.00% <100.00%> (ø)

ogusa/parameters.py
84.68% <100.00%> (-0.20%)
:arrow_down:

... and 5 more

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 223fd0a...223fd0a. Read the comment docs.

@rickecon This PR is ready for review.

@jdebacker . The tests timed out on the Travis CI testing for Python 3.7. The last test to pass in the 3.7 CI unit tests was:
ogusa/tests/test_get_micro_data.py::test_get_data[Baseline] Running current law policy baseline
Running current law policy baseline
Year:  2029
Year:  2030

Right after that, the CI testing started giving Dask worker memory warnings like the following,
distributed.worker - WARNING - Memory use is high but worker has no data to store to disk.  Perhaps some other process is leaking memory?  Process memory: 3.12 GB -- Worker memory limit: 4.18 GB

and the Python 3.7 testing stopped with the following message.
The job exceeded the maximum time limit for jobs, and has been terminated.

This is a Dask parallelism issue. As is noted in Issue #562, we should probably calculate the total amount of RAM available to the Travis CI cores, divide that by the number of cores, and then try to stay under 60% of that on each core.

@rickecon I restarted the test for 3.7.
I'm not too worried about the dask issue on Travis CI.  It's simple enough to try the test again for those instances when a worker runs into an issue.  This is about the 3rd time this has happened to me in the last 2 weeks and I've always has success on the second attempt.
If we are hitting the time limit, we can flag some additional tests to not run on Travis CI.


Adds export for promo space

When I went to use this in Eigen, the new helper wasn't visible. Looks like new files need to be added here.

:rocket: PR was released in v1.18.0 :rocket:


Protocol general context

Protocol general context

Changes 👷♀

Generalized AjnaGeneralContext

How to test 🧪

- step 1 ...

As we are trying to come up with a standard for handling lending protocols. What do you think about this crazy idea to forget about borrow | multiply positions. How about having a position (probably it would be just current multiplyPosition), as the multiply is just Summer.fi name and does not have any influence how the position looks like from the blockchain perspective. The difference would be that the details section and some labels in form. Especially when product wants to add all multiply features to borrow it makes it easer to maintain just one state. @piekczyk @piotrwitek @piotrkonowrocki ?

@piekczyk said it's old POC


Application Insights integration

Hey,
Good job with the project, it is always nice to see another DDD/CQRS open source projects.
Have ever you thought about integration with Application Insights? It could be good for performing/logging/diagnostics/alerting etc.
It has worked well in company project, especially that AI has possibility to inject into pipeline and add custom headers like CorrelationID

Hi @GetoXs
I plan to host this application someday in Azure so integration with Application Insights will be natural. However, I did not have time to that, yet.


SUTD Cuesports

Name of Student Organisation
Cuesports Club
Cluster
Sports
Classification
Fifth Row
Description
A fifth row to pick up pool. Ranging from newcomers who want to learn pool as an interest and social skill, to veterans who want to practice to achieve competitive excellence. All inclusive and all welcoming.
Training / Meeting Timings
Play times are every weekday 3pm-10pm
Competitive training is Monday 7pm-10pm
Student Organisation Introduction Video
https://youtu.be/78YRP8FqOPk
Name / Contact of President
Sharan/ @Sharan2325 (Vice President)
Other Relevant Links
Instagram: @sutd.cuesports
https://www.instagram.com/sutd.cuesports/
Registration Form: https://forms.office.com/Pages/ResponsePage.aspx?id=drd2NJDpck-5UGJImDFiPXkogzVPmqZLq7M4VEwgYItUOFk2N05UQ1dKTk1SOURPMjNUS0RDVzBBNC4u
(You will be invited to the Telegram chat group upon successful registration)

This is good, thank you for submitting.

Hi @Sorahawk  , thanks for submitting your fifthrow proposal!
Just wanted to get a bit more detail from you so that we can provide more precise information.
Could you provide the location/locations of the session in the proposal (add in with edit)?
Thank you!


Pass env variables and system props as string, closes CLOUD-368

Motivation:

system props can't be passed in the command line
env variables can't be passed to the gradle plugin

Modification:

use new version of the enterprise commons plugin
system props can be passed as a string in command line
env variables can be passed as a string, or in the build.gradle file

@ccedric Please update commons version so PR compiles


Fix issue 821

add what is missing regarding the issue description
https://github.com/duo-labs/cloudmapper/issues/821

I want to collect this properly, recursively.


Updated CONTRIBUTING.md

Fixes #___

Updated CONTRIBUTING.md

Screenshots and/or Screen Recordings

Checklist before requesting a review

[ ] I have read through CONTRIBUTING.MD
[ ] I have checked that no other PRs are out for the same issue
[ ] I have performed a self-review of my code
[ ] I have commented my code
[ ] I have tested my code
[ ] I have ensured all dependent changes have already been merged
[ ] I know this code generates no new errors or warning

Also please make sure to fill out your PR. Once that, and the changes requested, have been done I can approve it!

Sorry I already committed same change you can now review and accept PR

Fixes #___

#17 Updated CONTRIBUTING.md

Checklist before requesting a review

[x] I have read through CONTRIBUTING.MD
[x] I have checked that no other PRs are out for the same issue
[x] I have performed a self-review of my code
[x] I have commented my code
[x] I have tested my code
[x] I have ensured all dependent changes have already been merged
[x] I know this code generates no new errors or warning