TypeError:无法读取属性' directoryExists'未定义的

时间:2016-09-14 16:52:47

标签: angular angular2-cli

通过1.0.0-beta.11-webpack.8将我的Angular 2 CLI项目从ng init更新为ng serve,并运行** 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. 会导致以下错误:

1.0.0-beta.11-webpack.8

3 个答案:

答案 0 :(得分:11)

临时修复。 对我来说只有一件事有效,并且正在进入我的库CD projects/{library}/tsconfig.lib.json: "annotateForClosureCompiler": true 将其从true更改为false。 我认为这可能是ngc中的问题。我也许找到了相关的https://github.com/angular/angular/pull/26738

来源 https://www.gitmemory.com/issue/angular/tsickle/1046/516028024

答案 1 :(得分:5)

只需在annotateForClosureCompiler上将false设置为tsconfig.lib.json

projects/{your_project_name}/tsconfig.lib.json示例:

{
  "compilerOptions": {
      /* */
  },
  "angularCompilerOptions": {
      "annotateForClosureCompiler": false,
      /* */
  },
}

答案 2 :(得分:1)

这是一个Angular CLI npm install awesome-typescript-loader@2.2.1 --save-dev 依赖项错误;您可以通过以下方式解决应用程序中的错误:

 Select min(b.date)
 from a
 join b
   on a.id = b.id
   and b.date >= a.date

或者,你可以rebuild Angular CLI locally with the dependency fix