angular-cli: Module build failed: TypeError: Cannot read property 'directoryExists' of undefined
Please provide us with the following information:
-
OS? Windows 7, 8 or 10. Linux (which distribution). Mac OSX (Yosemite? El Capitan?)
Linux, Ubuntu 14.04
-
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
- 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.
- 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"
}
}
About this issue
- Original URL
- State: closed
- Created 8 years ago
- Reactions: 17
- Comments: 34 (8 by maintainers)
Commits related to this issue
- fix: Set awesome-typescript-loader version to 2.2.1 The most recent update to awesome-typescript-loader is breaking new builds, hard coding the version to 2.2.1 resolves the issue for now Fixes is... — committed to JSMike/angular-cli by JSMike 8 years ago
- Bug building: https://github.com/angular/angular-cli/issues/1997 — committed to actimeo/simmage-ui by feloy 8 years ago
- Sets verision of awesome-typescript-loader to 2.2.1 due angular/angular-cli#1997 — committed to GregOnNet/angular2-testing-playground by deleted user 8 years ago
- Add "awesome-typescript-loader" fix as temporary workaround (https://github.com/angular/angular-cli/issues/1997) — committed to Nolanus/ngx-page-scroll by Nolanus 8 years ago
- added definition of transitive dependency fix taken from: https://github.com/angular/angular-cli/issues/1997 — committed to matthiasbalke/infiniboard by matthiasbalke 8 years ago
- Merge pull request #123 from niceilm/master i found issue https://github.com/angular/angular-cli/issues/1997 — committed to swimlane/ngx-datatable by amcdnl 8 years ago
- Migration to angular-cli / angular 2.0.0 (#108) * added generated angular2 project * added AdminLTE2 theme * applied infiniboard index.html * fixed layout * added routing added pageNotFo... — committed to reflectoring/infiniboard by matthiasbalke 8 years ago
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@fredrik-lundin You can just add “awesome-typescript-loader”: “2.2.1” to your package.json.
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.
Yeah, fix here:
Thanks guys
@waterscar That’s the magic of dynamic transitive dependencies. angular-cli declares the dependency as
"awesome-typescript-loader": "^2.2.1",
, the^
is what’s important here. That means (in simplified terms): “Any version of the awesome-typescript-loader that looks like ‘2.x.x’”.At the time the developers declared this dependency, version 2.2.1 was the current version and it worked. But what if the awesome-typescript-loader project publishes new versions 2.2.2 and 2.2.3? Anyone who
npm build
s his project from that point in time on will get the new 2.2.3 version, which in this case is either not backward compatible (enough) or has a bug.Whatever it is, dynamic transitive dependencies are bad and we should stop using them.
Edit: oh and the reason it works when manually specified is that by not putting a
^
in your dependency declaration, you say “I want exactly version 2.2.1”, and since this matches angular-cli’s wish for “something like 2.x.x”, npm choses the older, working version.Dynamic transitive dependencies in action… 😦 why not avoid
^
's and~
's in version declarations altogether?that didn’t work for me
Yeah just ran into this as well. Adding
"awesome-typescript-loader": "2.2.1"
to the devDependencies worked as a temp fix.+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
@Toadskin Did you try pinning
"typescript": "2.0.0"
? I had a lot of errors after generating the project, because a newer typescript version was choosen.Thanks! Worked as a temporary (😉) fix on an existing project locally and propagated well to the related Travis test config.
@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.