angular-cli icon indicating copy to clipboard operation
angular-cli copied to clipboard

Module build failed: TypeError: Cannot read property 'directoryExists' of undefined

Open aderbas opened this issue 10 years ago • 34 comments

Please provide us with the following information:

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

    Linux, Ubuntu 14.04

  2. Versions. Please run ng --version. If there's nothing outputted, please run in a Terminal: node --version and paste the result here:

$ ng --version
Could not start watchman; falling back to NodeWatcher for file system events.
Visit http://ember-cli.com/user-guide/#watchman for more info.
angular-cli: 1.0.0-beta.11-webpack.8
node: 6.5.0
os: linux x64
  1. Repro steps. Was this an app that wasn't created using the CLI? What change did you do on your code? etc.

I had the error on a project and decided to create a new one for testing.

$ ng new apptest2
$ cd apptest2
$ ng build

I have not changed anything.

  1. The log given by the failure. Normally this include a stack trace and some more information.
$ ng build
Could not start watchman; falling back to NodeWatcher for file system events.
Visit http://ember-cli.com/user-guide/#watchman for more info.
 10% building modules 6/12 modules 6 active ...de_modules/script-loader/addScript.jsTypeError: Cannot read property 'directoryExists' of undefined
    at Object.getAutomaticTypeDirectiveNames (/var/www/html/apptest2/node_modules/typescript/lib/typescript.js:43865:17)
    at State.loadTypesFromConfig (/var/www/html/apptest2/node_modules/awesome-typescript-loader/src/host.ts:150:36)
    at new State (/var/www/html/apptest2/node_modules/awesome-typescript-loader/src/host.ts:144:14)
    at Object.ensureInstance (/var/www/html/apptest2/node_modules/awesome-typescript-loader/src/instance.ts:150:19)
    at compiler (/var/www/html/apptest2/node_modules/awesome-typescript-loader/src/index.ts:37:20)
    at Object.loader (/var/www/html/apptest2/node_modules/awesome-typescript-loader/src/index.ts:18:18)
    at LOADER_EXECUTION (/var/www/html/apptest2/node_modules/loader-runner/lib/LoaderRunner.js:95:14)
    at runSyncOrAsync (/var/www/html/apptest2/node_modules/loader-runner/lib/LoaderRunner.js:96:4)
    at iterateNormalLoaders (/var/www/html/apptest2/node_modules/loader-runner/lib/LoaderRunner.js:200:2)
    at iterateNormalLoaders (/var/www/html/apptest2/node_modules/loader-runner/lib/LoaderRunner.js:189:10)
    at /var/www/html/apptest2/node_modules/loader-runner/lib/LoaderRunner.js:204:3
    at Object.context.callback (/var/www/html/apptest2/node_modules/loader-runner/lib/LoaderRunner.js:87:13)
    at Object.module.exports (/var/www/html/apptest2/node_modules/angular2-template-loader/index.js:32:10)
    at LOADER_EXECUTION (/var/www/html/apptest2/node_modules/loader-runner/lib/LoaderRunner.js:95:14)
    at runSyncOrAsync (/var/www/html/apptest2/node_modules/loader-runner/lib/LoaderRunner.js:96:4)
    at iterateNormalLoaders (/var/www/html/apptest2/node_modules/loader-runner/lib/LoaderRunner.js:200:2)
    at /var/www/html/apptest2/node_modules/loader-runner/lib/LoaderRunner.js:173:4
    at Storage.finished (/var/www/html/apptest2/node_modules/enhanced-resolve/lib/CachedInputFileSystem.js:39:16)
    at /var/www/html/apptest2/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 (/var/www/html/apptest2/node_modules/typescript/lib/typescript.js:43865:17)\n    at State.loadTypesFromConfig (/var/www/html/apptest2/node_modules/awesome-typescript-loader/src/host.ts:150:36)\n    at new State (/var/www/html/apptest2/node_modules/awesome-typescript-loader/src/host.ts:144:14)\n    at Object.ensureInstance (/var/www/html/apptest2/node_modules/awesome-typescript-loader/src/instance.ts:150:19)\n    at compiler (/var/www/html/apptest2/node_modules/awesome-typescript-loader/src/index.ts:37:20)\n    at Object.loader (/var/www/html/apptest2/node_modules/awesome-typescript-loader/src/index.ts:18:18)\n    at LOADER_EXECUTION (/var/www/html/apptest2/node_modules/loader-runner/lib/LoaderRunner.js:95:14)\n    at runSyncOrAsync (/var/www/html/apptest2/node_modules/loader-runner/lib/LoaderRunner.js:96:4)\n    at iterateNormalLoaders (/var/www/html/apptest2/node_modules/loader-runner/lib/LoaderRunner.js:200:2)\n    at iterateNormalLoaders (/var/www/html/apptest2/node_modules/loader-runner/lib/LoaderRunner.js:189:10)\n    at /var/www/html/apptest2/node_modules/loader-runner/lib/LoaderRunner.js:204:3\n    at Object.context.callback (/var/www/html/apptest2/node_modules/loader-runner/lib/LoaderRunner.js:87:13)\n    at Object.module.exports (/var/www/html/apptest2/node_modules/angular2-template-loader/index.js:32:10)\n    at LOADER_EXECUTION (/var/www/html/apptest2/node_modules/loader-runner/lib/LoaderRunner.js:95:14)\n    at runSyncOrAsync (/var/www/html/apptest2/node_modules/loader-runner/lib/LoaderRunner.js:96:4)\n    at iterateNormalLoaders (/var/www/html/apptest2/node_modules/loader-runner/lib/LoaderRunner.js:200:2)\n    at /var/www/html/apptest2/node_modules/loader-runner/lib/LoaderRunner.js:173:4\n    at Storage.finished (/var/www/html/apptest2/node_modules/enhanced-resolve/lib/CachedInputFileSystem.js:39:16)\n    at /var/www/html/apptest2/node_modules/enhanced-resolve/node_modules/graceful-fs/graceful-fs.js:78:16\n    at FSReqWrap.readFileAfterClose [as oncomplete] (fs.js:445:3)'
1044ms building modules                                                              
1ms sealing 
0ms optimizing 
0ms basic module optimization 
1ms module optimization 
0ms advanced module optimization 
2ms basic chunk optimization        
0ms chunk optimization 
0ms advanced chunk optimization 
1ms module and chunk tree optimization 
1ms module reviving 
0ms module order optimization 
1ms module id optimization 
2ms chunk reviving 
0ms chunk order optimization 
1ms chunk id optimization 
2ms hashing 
0ms module assets processing 
5ms chunk assets processing 
0ms additional chunk assets processing 
0ms recording 
0ms additional asset processing 
72ms chunk asset optimization
31ms asset optimization
6ms emitting 
Hash: bbc4834236db6d10b21a
Version: webpack 2.1.0-beta.21
Time: 1189ms
            Asset       Size  Chunks             Chunk Names
 styles.bundle.js      29 kB    0, 3  [emitted]  styles
scripts.bundle.js     128 kB    1, 3  [emitted]  scripts
   main.bundle.js  999 bytes    2, 3  [emitted]  main
        inline.js    5.53 kB       3  [emitted]  inline
       styles.map    37.5 kB    0, 3  [emitted]  styles
      scripts.map     150 kB    1, 3  [emitted]  scripts
         main.map   91 bytes    2, 3  [emitted]  main
       inline.map    5.59 kB       3  [emitted]  inline
       index.html  866 bytes          [emitted]  
assets/.npmignore    0 bytes          [emitted]  
chunk    {0} styles.bundle.js, styles.map (styles) 28.5 kB {3} [initial] [rendered]
chunk    {1} scripts.bundle.js, scripts.map (scripts) 128 kB {0} [initial] [rendered]
chunk    {2} main.bundle.js, main.map (main) 793 bytes {1} [initial] [rendered]
chunk    {3} inline.js, inline.map (inline) 0 bytes [entry] [rendered]

ERROR in ./src/main.ts
Module build failed: TypeError: Cannot read property 'directoryExists' of undefined
    at Object.getAutomaticTypeDirectiveNames (/var/www/html/apptest2/node_modules/typescript/lib/typescript.js:43865:17)
    at State.loadTypesFromConfig (/var/www/html/apptest2/node_modules/awesome-typescript-loader/src/host.ts:150:36)
    at new State (/var/www/html/apptest2/node_modules/awesome-typescript-loader/src/host.ts:144:14)
    at Object.ensureInstance (/var/www/html/apptest2/node_modules/awesome-typescript-loader/src/instance.ts:150:19)
    at compiler (/var/www/html/apptest2/node_modules/awesome-typescript-loader/src/index.ts:37:20)
    at Object.loader (/var/www/html/apptest2/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  3.15 kB       0       
    chunk    {0} index.html 687 bytes [entry] [rendered]
  • package.json:
{
  "name": "apptest2",
  "version": "0.0.0",
  "license": "MIT",
  "angular-cli": {},
  "scripts": {
    "start": "ng serve",
    "lint": "tslint \"src/**/*.ts\"",
    "test": "ng test",
    "pree2e": "webdriver-manager update",
    "e2e": "protractor"
  },
  "private": true,
  "dependencies": {
    "@angular/common": "2.0.0-rc.5",
    "@angular/compiler": "2.0.0-rc.5",
    "@angular/core": "2.0.0-rc.5",
    "@angular/forms": "0.3.0",
    "@angular/http": "2.0.0-rc.5",
    "@angular/platform-browser": "2.0.0-rc.5",
    "@angular/platform-browser-dynamic": "2.0.0-rc.5",
    "@angular/router": "3.0.0-rc.1",
    "core-js": "^2.4.0",
    "leaflet": "^0.7.7",
    "rxjs": "5.0.0-beta.11",
    "ts-helpers": "^1.1.1",
    "zone.js": "0.6.12"
  },
  "devDependencies": {
    "@types/jasmine": "^2.2.30",
    "@types/leaflet": "^1.0.31",
    "angular-cli": "1.0.0-beta.11-webpack.8",
    "codelyzer": "~0.0.26",
    "jasmine-core": "2.4.1",
    "jasmine-spec-reporter": "2.5.0",
    "karma": "0.13.22",
    "karma-chrome-launcher": "0.2.3",
    "karma-jasmine": "0.3.8",
    "karma-remap-istanbul": "^0.2.1",
    "protractor": "4.0.3",
    "ts-node": "1.2.1",
    "tslint": "3.13.0",
    "typescript": "2.0.0"
  }
}

aderbas avatar Sep 06 '16 14:09 aderbas

+1

sholzmayer avatar Sep 06 '16 15:09 sholzmayer

+1

Ranfty avatar Sep 06 '16 15:09 Ranfty

+1

danyel avatar Sep 06 '16 15:09 danyel

+1

osmanm786 avatar Sep 06 '16 15:09 osmanm786

+1

tomwanzek avatar Sep 06 '16 15:09 tomwanzek

+1 but not on my computer. I did the migration from RC4 to RC5 between monday and Wednesday (last week) and I did not have the issue. My collegue just merge my work today and he starts to do the migration (npm install -g etc) and has this issue.

thlem avatar Sep 06 '16 15:09 thlem

I just started a new project based on the current master and received the same error upon ng serve

JSMike avatar Sep 06 '16 15:09 JSMike

Issue is with awesome-typescript-loader, i removed the ^ from the angular-cli package.json to use version 2.2.1 specifically and now it's working

JSMike avatar Sep 06 '16 15:09 JSMike

that didn't work for me

danyel avatar Sep 06 '16 16:09 danyel

+1

My package.json doesn't even include awesome-typescript-loader. Project created with, and still using angular-cli: 1.0.0-beta.11-webpack.8.

Works on one PC: win 10, node 6.2.1, npm 3.10.7 Not on another PC: win 7, node 6.5.0, npm 3.10.3

ERROR in ./src/main.ts Module build failed: TypeError: Cannot read property 'directoryExists' of undefined at Object.getAutomaticTypeDirectiveNames (C:\git-repos\ang2-study-helper\node_modules\typescript\lib\typescript.js:43865:17) at State.loadTypesFromConfig (C:\git-repos\ang2-study-helper\node_modules\angular-cli\node_modules\awesome-typescript-loader\src\host.ts:150:36) at new State (C:\git-repos\ang2-study-helper\node_modules\angular-cli\node_modules\awesome-typescript-loader\src\host.ts:144:14) at Object.ensureInstance (C:\git-repos\ang2-study-helper\node_modules\angular-cli\node_modules\awesome-typescript-loader\src\instance.ts:150:19) at compiler (C:\git-repos\ang2-study-helper\node_modules\angular-cli\node_modules\awesome-typescript-loader\src\index.ts:37:20) at Object.loader (C:\git-repos\ang2-study-helper\node_modules\angular-cli\node_modules\awesome-typescript-loader\src\index.ts:18:18) @ multi main

fredrik-lundin avatar Sep 06 '16 17:09 fredrik-lundin

@JSMike how I generate the bin file of the angular-cli with the change you made in package.json? @fredrik-lundin This change was made in package.json of angular-cli, not in created project.

aderbas avatar Sep 06 '16 17:09 aderbas

@aderbas See this article on cloning angular-cli, using npm link and ng new <project-name> --link-cli

JSMike avatar Sep 06 '16 17:09 JSMike

@fredrik-lundin You can just add "awesome-typescript-loader": "2.2.1" to your package.json.

jianliao avatar Sep 06 '16 17:09 jianliao

"awesome-typescript-loader": "2.2.1" fixed it!!

webartistkb avatar Sep 06 '16 17:09 webartistkb

Yeah, fix here:

$ ng new foobar
$ cd foobar
$ npm install [email protected] --save-dev
$ ng serve

Thanks guys

aderbas avatar Sep 06 '16 18:09 aderbas

Thanks! Worked as a temporary (:wink:) fix on an existing project locally and propagated well to the related Travis test config.

tomwanzek avatar Sep 06 '16 19:09 tomwanzek

Dynamic transitive dependencies in action... :( why not avoid ^'s and ~'s in version declarations altogether?

netmikey avatar Sep 06 '16 19:09 netmikey

As other has said, can we please not use ^? I just spotted a ^ on the way in (for TS ^2.0.2) and asked about it there. It seems like now is a good stop to proactively stop the breakage which has hit CLI several times over the last several months.

kylecordes avatar Sep 06 '16 20:09 kylecordes

Hmm. I have this exact issue, also using awesome-typescript-loader. Was already using v2.2.1 when the issue showed up - I see the issue only on Linux, but the same build works fine on Mac OS X Unix.

So, presumably using v2.2.1 would not be a fix, since the error occurs with that version.

don-bluelinegrid avatar Sep 06 '16 20:09 don-bluelinegrid

Yeah just ran into this as well. Adding "awesome-typescript-loader": "2.2.1" to the devDependencies worked as a temp fix.

coryrylan avatar Sep 06 '16 22:09 coryrylan