title: ERROR in ./src/$$_gendir/app/app.module.ngfactory.ts: Cannot read property 'flags' of undefined
body: <p>I'm working on a project based on the <a href="https://github.com/maximegris/angular-electron/tree/angular4" rel="nofollow noreferrer">Angular Electron Repo</a>, using the Angular 4 versions. When I try to run <code>npm run electron:mac</code>, which in turn runs <code>webpack --display-error-details</code>, the webpack build runs until it hits this error message:</p>
  
  <pre><code>[XS25] ./src/polyfills.ts 2.45 kB {0} [built]
     [0] multi ./src/main.ts 28 bytes {2} [built]
  [dvQ4] ./src/environments/index.ts 252 bytes {2} [built]
  [kke6] ./src/$$_gendir/app/app.module.ngfactory.ts 3.16 kB {2} [built] [failed] [1 error]
  [x35b] ./src/main.ts 376 bytes {2} [built]
     [1] multi ./src/polyfills.ts 28 bytes {0} [built]
     [2] multi ./src/styles.scss 28 bytes {1} [built]
      + 147 hidden modules
  
  ERROR in ./src/$$_gendir/app/app.module.ngfactory.ts
  Module build failed: TypeError: Cannot read property 'flags' of undefined
      at resolveAlias (/Users/Evan/Documents/Programming/electron/groupme-client/node_modules/typescript/lib/typescript.js:24003:37)
      at checkAliasSymbol (/Users/Evan/Documents/Programming/electron/groupme-client/node_modules/typescript/lib/typescript.js:42692:26)
      at checkImportBinding (/Users/Evan/Documents/Programming/electron/groupme-client/node_modules/typescript/lib/typescript.js:42722:13)
      at checkImportDeclaration (/Users/Evan/Documents/Programming/electron/groupme-client/node_modules/typescript/lib/typescript.js:42740:29)
      at checkSourceElement (/Users/Evan/Documents/Programming/electron/groupme-client/node_modules/typescript/lib/typescript.js:43052:28)
      at Object.forEach (/Users/Evan/Documents/Programming/electron/groupme-client/node_modules/typescript/lib/typescript.js:1500:30)
      at checkSourceFileWorker (/Users/Evan/Documents/Programming/electron/groupme-client/node_modules/typescript/lib/typescript.js:43125:20)
      at checkSourceFile (/Users/Evan/Documents/Programming/electron/groupme-client/node_modules/typescript/lib/typescript.js:43105:13)
      at getDiagnosticsWorker (/Users/Evan/Documents/Programming/electron/groupme-client/node_modules/typescript/lib/typescript.js:43169:17)
      at getDiagnostics (/Users/Evan/Documents/Programming/electron/groupme-client/node_modules/typescript/lib/typescript.js:43155:24)
      at Object.getEmitResolver (/Users/Evan/Documents/Programming/electron/groupme-client/node_modules/typescript/lib/typescript.js:23078:13)
      at /Users/Evan/Documents/Programming/electron/groupme-client/node_modules/typescript/lib/typescript.js:70539:69
      at runWithCancellationToken (/Users/Evan/Documents/Programming/electron/groupme-client/node_modules/typescript/lib/typescript.js:70295:24)
      at getDeclarationDiagnosticsForFileNoCache (/Users/Evan/Documents/Programming/electron/groupme-client/node_modules/typescript/lib/typescript.js:70538:20)
      at getAndCacheDiagnostics (/Users/Evan/Documents/Programming/electron/groupme-client/node_modules/typescript/lib/typescript.js:70551:26)
      at getDeclarationDiagnosticsWorker (/Users/Evan/Documents/Programming/electron/groupme-client/node_modules/typescript/lib/typescript.js:70535:20)
      at getDeclarationDiagnosticsForFile (/Users/Evan/Documents/Programming/electron/groupme-client/node_modules/typescript/lib/typescript.js:70564:56)
      at getDiagnosticsHelper (/Users/Evan/Documents/Programming/electron/groupme-client/node_modules/typescript/lib/typescript.js:70254:24)
      at Object.getDeclarationDiagnostics (/Users/Evan/Documents/Programming/electron/groupme-client/node_modules/typescript/lib/typescript.js:70276:24)
      at TypeScriptFileRefactor.getDiagnostics (/Users/Evan/Documents/Programming/electron/groupme-client/node_modules/@ngtools/webpack/src/refactor.js:52:60)
      at Promise.resolve.then.then.then.then (/Users/Evan/Documents/Programming/electron/groupme-client/node_modules/@ngtools/webpack/src/loader.js:505:46)
      at &lt;anonymous&gt;
      at process._tickCallback (internal/process/next_tick.js:188:7)
   @ ./src/main.ts 3:0-74
   @ multi ./src/main.ts
  </code></pre>
  
  <p>I'm not sure what the error message is referring to, no part of my application uses the property <code>flags</code>, including in <code>app.module.ts</code> or <code>main.ts</code>. </p>
  
  <p>I have seen many answers and threads which contain solutions for installing various versions of packages. Things such as upgrading <code>@angular/cli</code> to 1.7.3 and upgrading Typescript to 2.6.2 have only caused other issues. I believe that the issue is not with my installed modules, as the Angular Electron repo provides a working application with an identical set of modules in <code>package.json</code>. </p>
  
  <pre><code>"scripts": {
      "ng": "ng",
      "lint": "ng lint",
      "start": "npm-run-all --parallel webpack:watch electron:serve",
      "webpack:watch": "webpack --watch",
      "start:web": "webpack-dev-server --content-base . --port 4200 --inline",
      "build:electron:main": "tsc main.ts --outDir dist &amp;&amp; copyfiles package.json dist &amp;&amp; cd dist &amp;&amp; npm install --prod &amp;&amp; cd ..",
      "build": "webpack --display-error-details &amp;&amp; npm run build:electron:main",
      "build:prod": "cross-env NODE_ENV=production npm run build",
      "electron:serve": "npm run build:electron:main &amp;&amp; electron ./dist --serve",
      "electron:test": "electron ./dist",
      "electron:dev": "npm run build &amp;&amp; electron ./dist",
      "electron:prod": "npm run build:prod &amp;&amp; electron ./dist",
      "electron:linux": "npm run build:prod &amp;&amp; node package.js --asar --platform=linux --arch=x64",
      "electron:windows": "npm run build:prod &amp;&amp; node package.js --asar --platform=win32 --arch=ia32",
      "electron:mac": "npm run build:prod &amp;&amp; node package.js --asar --platform=darwin --arch=x64",
      "test": "karma start ./karma.conf.js",
      "pree2e": "webdriver-manager update --standalone false --gecko false --quiet &amp;&amp; npm run build",
      "e2e": "protractor ./protractor.conf.js"
    },
    "dependencies": {
      "@angular/common": "4.4.6",
      "@angular/compiler": "4.4.6",
      "@angular/core": "4.4.6",
      "@angular/forms": "4.4.6",
      "@angular/http": "4.4.6",
      "@angular/platform-browser": "4.4.6",
      "@angular/platform-browser-dynamic": "4.4.6",
      "@angular/router": "4.4.6",
      "core-js": "2.4.1",
      "enhanced-resolve": "3.3.0",
      "rxjs": "5.4.3",
      "zone.js": "0.8.17"
    },
    "devDependencies": {
      "@angular/cli": "1.4.9",
      "@angular/compiler-cli": "4.4.6",
      "@types/core-js": "0.9.36",
      "@types/jasmine": "2.5.54",
      "@types/node": "7.0.7",
      "autoprefixer": "7.1.4",
      "codelyzer": "3.2.0",
      "copyfiles": "1.2.0",
      "cross-env": "5.0.5",
      "css-loader": "0.28.7",
      "cssnano": "3.10.0",
      "electron": "1.7.8",
      "electron-packager": "9.1.0",
      "electron-reload": "1.2.1",
      "exports-loader": "0.6.4",
      "file-loader": "0.11.2",
      "html-loader": "0.5.1",
      "istanbul-instrumenter-loader": "3.0.0",
      "jasmine-core": "2.8.0",
      "jasmine-spec-reporter": "4.2.1",
      "json-loader": "0.5.7",
      "karma": "1.7.1",
      "karma-chrome-launcher": "2.2.0",
      "karma-cli": "1.0.1",
      "karma-coverage-istanbul-reporter": "1.3.0",
      "karma-jasmine": "1.1.0",
      "karma-jasmine-html-reporter": "0.2.2",
      "karma-sourcemap-loader": "0.3.7",
      "less-loader": "4.0.5",
      "minimist": "1.2.0",
      "mkdirp": "0.5.1",
      "npm-run-all": "^4.1.1",
      "postcss-loader": "2.0.6",
      "postcss-url": "7.1.2",
      "protractor": "5.1.2",
      "raw-loader": "0.5.1",
      "sass-loader": "6.0.6",
      "script-loader": "0.7.1",
      "source-map-loader": "0.2.1",
      "style-loader": "0.18.2",
      "stylus-loader": "3.0.1",
      "ts-node": "3.3.0",
      "tslint": "5.7.0",
      "typescript": "^2.5.3",
      "url-loader": "0.5.9",
      "webdriver-manager": "12.0.6",
      "webpack": "3.6.0",
      "webpack-dev-server": "2.8.2"
    },
  </code></pre>
  
  <p>I'm very much out of answers here, any help is appreciated. </p>