angularangular2-cli

TypeError: Cannot read property 'directoryExists' of undefined


Updating my Angular 2 CLI project from 1.0.0-beta.11-webpack.2 to 1.0.0-beta.11-webpack.8 via ng init, and running ng serve results in the following error:

** NG Live Development Server is running on http://localhost:4200. **
 10% building modules 4/7 modules 3 active ...ode_modules/style-loader/addStyles.jsTypeError: Cannot read property 'directoryExists' of undefined
    at Object.getAutomaticTypeDirectiveNames (/home/jan/src/fm-repos/fm-ui/node_modules/typescript/lib/typescript.js:43865:17)
    at State.loadTypesFromConfig (/home/jan/src/fm-repos/fm-ui/node_modules/awesome-typescript-loader/src/host.ts:150:36)
    at new State (/home/jan/src/fm-repos/fm-ui/node_modules/awesome-typescript-loader/src/host.ts:144:14)
    at Object.ensureInstance (/home/jan/src/fm-repos/fm-ui/node_modules/awesome-typescript-loader/src/instance.ts:150:19)
    at compiler (/home/jan/src/fm-repos/fm-ui/node_modules/awesome-typescript-loader/src/index.ts:37:20)
    at Object.loader (/home/jan/src/fm-repos/fm-ui/node_modules/awesome-typescript-loader/src/index.ts:18:18)
    at LOADER_EXECUTION (/home/jan/src/fm-repos/fm-ui/node_modules/loader-runner/lib/LoaderRunner.js:95:14)
    at runSyncOrAsync (/home/jan/src/fm-repos/fm-ui/node_modules/loader-runner/lib/LoaderRunner.js:96:4)
    at iterateNormalLoaders (/home/jan/src/fm-repos/fm-ui/node_modules/loader-runner/lib/LoaderRunner.js:200:2)
    at iterateNormalLoaders (/home/jan/src/fm-repos/fm-ui/node_modules/loader-runner/lib/LoaderRunner.js:189:10)
    at /home/jan/src/fm-repos/fm-ui/node_modules/loader-runner/lib/LoaderRunner.js:204:3
    at Object.context.callback (/home/jan/src/fm-repos/fm-ui/node_modules/loader-runner/lib/LoaderRunner.js:87:13)
    at Object.module.exports (/home/jan/src/fm-repos/fm-ui/node_modules/angular2-template-loader/index.js:32:10)
    at LOADER_EXECUTION (/home/jan/src/fm-repos/fm-ui/node_modules/loader-runner/lib/LoaderRunner.js:95:14)
    at runSyncOrAsync (/home/jan/src/fm-repos/fm-ui/node_modules/loader-runner/lib/LoaderRunner.js:96:4)
    at iterateNormalLoaders (/home/jan/src/fm-repos/fm-ui/node_modules/loader-runner/lib/LoaderRunner.js:200:2)
    at /home/jan/src/fm-repos/fm-ui/node_modules/loader-runner/lib/LoaderRunner.js:173:4
    at Storage.finished (/home/jan/src/fm-repos/fm-ui/node_modules/enhanced-resolve/lib/CachedInputFileSystem.js:39:16)
    at /home/jan/src/fm-repos/fm-ui/node_modules/enhanced-resolve/node_modules/graceful-fs/graceful-fs.js:78:16
    at FSReqWrap.readFileAfterClose [as oncomplete] (fs.js:445:3) 'TypeError: Cannot read property \'directoryExists\' of undefined\n    at Object.getAutomaticTypeDirectiveNames (/home/jan/src/fm-repos/fm-ui/node_modules/typescript/lib/typescript.js:43865:17)\n    at State.loadTypesFromConfig (/home/jan/src/fm-repos/fm-ui/node_modules/awesome-typescript-loader/src/host.ts:150:36)\n    at new State (/home/jan/src/fm-repos/fm-ui/node_modules/awesome-typescript-loader/src/host.ts:144:14)\n    at Object.ensureInstance (/home/jan/src/fm-repos/fm-ui/node_modules/awesome-typescript-loader/src/instance.ts:150:19)\n    at compiler (/home/jan/src/fm-repos/fm-ui/node_modules/awesome-typescript-loader/src/index.ts:37:20)\n    at Object.loader (/home/jan/src/fm-repos/fm-ui/node_modules/awesome-typescript-loader/src/index.ts:18:18)\n    at LOADER_EXECUTION (/home/jan/src/fm-repos/fm-ui/node_modules/loader-runner/lib/LoaderRunner.js:95:14)\n    at runSyncOrAsync (/home/jan/src/fm-repos/fm-ui/node_modules/loader-runner/lib/LoaderRunner.js:96:4)\n    at iterateNormalLoaders (/home/jan/src/fm-repos/fm-ui/node_modules/loader-runner/lib/LoaderRunner.js:200:2)\n    at iterateNormalLoaders (/home/jan/src/fm-repos/fm-ui/node_modules/loader-runner/lib/LoaderRunner.js:189:10)\n    at /home/jan/src/fm-repos/fm-ui/node_modules/loader-runner/lib/LoaderRunner.js:204:3\n    at Object.context.callback (/home/jan/src/fm-repos/fm-ui/node_modules/loader-runner/lib/LoaderRunner.js:87:13)\n    at Object.module.exports (/home/jan/src/fm-repos/fm-ui/node_modules/angular2-template-loader/index.js:32:10)\n    at LOADER_EXECUTION (/home/jan/src/fm-repos/fm-ui/node_modules/loader-runner/lib/LoaderRunner.js:95:14)\n    at runSyncOrAsync (/home/jan/src/fm-repos/fm-ui/node_modules/loader-runner/lib/LoaderRunner.js:96:4)\n    at iterateNormalLoaders (/home/jan/src/fm-repos/fm-ui/node_modules/loader-runner/lib/LoaderRunner.js:200:2)\n    at /home/jan/src/fm-repos/fm-ui/node_modules/loader-runner/lib/LoaderRunner.js:173:4\n    at Storage.finished (/home/jan/src/fm-repos/fm-ui/node_modules/enhanced-resolve/lib/CachedInputFileSystem.js:39:16)\n    at /home/jan/src/fm-repos/fm-ui/node_modules/enhanced-resolve/node_modules/graceful-fs/graceful-fs.js:78:16\n    at FSReqWrap.readFileAfterClose [as oncomplete] (fs.js:445:3)'
1753ms building modules                                                               
2ms sealing 
0ms optimizing 
0ms basic module optimization 
2ms module optimization 
0ms advanced module optimization 
4ms basic chunk optimization        
0ms chunk optimization 
0ms advanced chunk optimization 
0ms module and chunk tree optimization 
10ms module reviving
0ms module order optimization 
1ms module id optimization 
1ms chunk reviving 
0ms chunk order optimization 
3ms chunk id optimization 
3ms hashing 
0ms module assets processing 
19ms chunk assets processing
1ms additional chunk assets processing 
0ms recording 
0ms additional asset processing 
192ms chunk asset optimization
40ms asset optimization
15ms emitting
Hash: 865ed065ce2165dac568
Version: webpack 2.1.0-beta.21
Time: 2067ms
            Asset       Size  Chunks             Chunk Names
   main.bundle.js     241 kB    0, 2  [emitted]  main
 styles.bundle.js    10.2 kB    1, 2  [emitted]  styles
        inline.js    5.53 kB       2  [emitted]  inline
         main.map     295 kB    0, 2  [emitted]  main
       styles.map      14 kB    1, 2  [emitted]  styles
       inline.map    5.59 kB       2  [emitted]  inline
       index.html  616 bytes          [emitted]  
assets/.npmignore    0 bytes          [emitted]  

ERROR in ./src/main.ts
Module build failed: TypeError: Cannot read property 'directoryExists' of undefined
    at Object.getAutomaticTypeDirectiveNames (/home/jan/src/fm-repos/fm-ui/node_modules/typescript/lib/typescript.js:43865:17)
    at State.loadTypesFromConfig (/home/jan/src/fm-repos/fm-ui/node_modules/awesome-typescript-loader/src/host.ts:150:36)
    at new State (/home/jan/src/fm-repos/fm-ui/node_modules/awesome-typescript-loader/src/host.ts:144:14)
    at Object.ensureInstance (/home/jan/src/fm-repos/fm-ui/node_modules/awesome-typescript-loader/src/instance.ts:150:19)
    at compiler (/home/jan/src/fm-repos/fm-ui/node_modules/awesome-typescript-loader/src/index.ts:37:20)
    at Object.loader (/home/jan/src/fm-repos/fm-ui/node_modules/awesome-typescript-loader/src/index.ts:18:18)
 @ multi main
Child html-webpack-plugin for "index.html":
         Asset     Size  Chunks       Chunk Names
    index.html  2.96 kB       0       
webpack: bundle is now VALID.

Solution

  • This is a Angular CLI 1.0.0-beta.11-webpack.8 dependency bug; you can work-around the bug in your application via:

    npm install awesome-typescript-loader@2.2.1 --save-dev
    

    Or, you can rebuild Angular CLI locally with the dependency fix.