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

ng build -prod Module not found: Error: Can't resolve './$$_gendir/app/app.module.ngfactory'

Open thaniri opened this issue 9 years ago • 156 comments

OS?

Windows 7 64 bit

Versions.

@angular/cli: 1.0.0-beta.30 node: 7.4.0 os: win32 x64 @angular/common: 2.4.6 @angular/compiler: 2.4.6 @angular/core: 2.4.6 @angular/forms: 2.4.6 @angular/http: 2.4.6 @angular/platform-browser: 2.4.6 @angular/platform-browser-dynamic: 2.4.6 @angular/router: 3.4.6 @angular/cli: 1.0.0-beta.30 @angular/compiler-cli: 2.4.6

Repro steps.

App started using angular cli

The log given by the failure.

This is from my command line:

ERROR in Unexpected value 'null' declared by the module 'AppModule in C:/Users/T haniri/Desktop/freecodecamp/myroute/src/app/app.module.ts'

ERROR in ./src/main.ts Module not found: Error: Can't resolve './$$_gendir/app/app.module.ngfactory' in 'C:\Users\Thaniri\Desktop\freecodecamp\myroute\src' @ ./src/main.ts 3:0-74 @ multi ./src/main.ts

Mention any other details that might be useful.

ng serve works fine, its just ng build -prod

Here are the contents of my main.ts file: `import { platformBrowserDynamic } from '@angular/platform-browser-dynamic'; import { enableProdMode } from '@angular/core'; import { environment } from './environments/environment'; import { AppModule } from './app/app.module';

if (environment.production) { enableProdMode(); }

platformBrowserDynamic().bootstrapModule(AppModule); `

If there is more information needed, please let me know. I am trying to learn how to deploy my Angular website.

thaniri avatar Feb 09 '17 05:02 thaniri

fwiw ... In case this might help others, I was able to resolve this error by updating both my global and project angular-cli from 1.0.3 to 1.3.1 (the latest as of this writing), per the instructions on the Angular CLI ReadMe. I didn't make any other changes to my project.

For me, the issue was happening only when doing an ng build --prod or ng serve --prod. In contrast, development builds (i.e., without the --prod) ran without error.

hafarey avatar Aug 18 '17 05:08 hafarey

Installing @angular/[email protected] fix this

iturn avatar Aug 23 '17 10:08 iturn

my previous @angular/[email protected] had conflict with npm packages.

-- upgrade global angular-cli to @latest

npm uninstall -g angular-cli npm cache clean npm install -g @angular/cli

your-angular-project-dir> npm install --save-dev @angular/cli@latest

after upgrade to @lastest, all works

johnrivelt avatar Aug 29 '17 06:08 johnrivelt

i have same problem after uninstall previous version of angular cli and then update to "@angular/cli": "^1.2.4", solve my issue my debug in terminal is

mrnull@mrnull-mrnull:~/Desktop/ecowalls$ ng build --env=prod Hash: 985921a97b2ef5b04336
Time: 24034ms chunk {0} 0.chunk.js, 0.chunk.js.map 1.08 MB {1} {2} {3} {5} [rendered] chunk {1} 1.chunk.js, 1.chunk.js.map 83 kB {0} {2} {3} {5} [rendered] chunk {2} 2.chunk.js, 2.chunk.js.map 15.4 kB {0} {1} {3} {5} [rendered] chunk {3} 3.chunk.js, 3.chunk.js.map 2.75 kB {0} {1} {2} {5} [rendered] chunk {4} polyfills.bundle.js, polyfills.bundle.js.map (polyfills) 178 kB {8} [initial] [rendered] chunk {5} main.bundle.js, main.bundle.js.map (main) 21.7 kB {7} [initial] [rendered] chunk {6} styles.bundle.js, styles.bundle.js.map (styles) 10.5 kB {8} [initial] [rendered] chunk {7} vendor.bundle.js, vendor.bundle.js.map (vendor) 3.25 MB [initial] [rendered] chunk {8} inline.bundle.js, inline.bundle.js.map (inline) 0 bytes [entry] [rendered]

ERROR in ./src/environments/environment.ts Module build failed: TypeError: Cannot read property 'flags' of undefined at getSymbolLinks (/home/mrnull/Desktop/ecowalls/node_modules/typescript/lib/typescript.js:26080:23) at getTypeOfVariableOrParameterOrProperty (/home/mrnull/Desktop/ecowalls/node_modules/typescript/lib/typescript.js:29345:25) at checkVariableLikeDeclaration (/home/mrnull/Desktop/ecowalls/node_modules/typescript/lib/typescript.js:43177:41) at checkVariableDeclaration (/home/mrnull/Desktop/ecowalls/node_modules/typescript/lib/typescript.js:43233:20) at checkSourceElement (/home/mrnull/Desktop/ecowalls/node_modules/typescript/lib/typescript.js:45111:28) at Object.forEach (/home/mrnull/Desktop/ecowalls/node_modules/typescript/lib/typescript.js:1449:30) at checkVariableStatement (/home/mrnull/Desktop/ecowalls/node_modules/typescript/lib/typescript.js:43242:16) at checkSourceElement (/home/mrnull/Desktop/ecowalls/node_modules/typescript/lib/typescript.js:45080:28) at Object.forEach (/home/mrnull/Desktop/ecowalls/node_modules/typescript/lib/typescript.js:1449:30) at checkSourceFileWorker (/home/mrnull/Desktop/ecowalls/node_modules/typescript/lib/typescript.js:45198:20) at checkSourceFile (/home/mrnull/Desktop/ecowalls/node_modules/typescript/lib/typescript.js:45178:13) at getDiagnosticsWorker (/home/mrnull/Desktop/ecowalls/node_modules/typescript/lib/typescript.js:45242:17) at getDiagnostics (/home/mrnull/Desktop/ecowalls/node_modules/typescript/lib/typescript.js:45228:24) at Object.getEmitResolver (/home/mrnull/Desktop/ecowalls/node_modules/typescript/lib/typescript.js:25898:13) at /home/mrnull/Desktop/ecowalls/node_modules/typescript/lib/typescript.js:67689:69 at runWithCancellationToken (/home/mrnull/Desktop/ecowalls/node_modules/typescript/lib/typescript.js:67447:24) @ ./src/main.ts 4:0-57 @ multi ./src/main.ts mrnull@mrnull-mrnull:~/Desktop/ecowalls$ mrnull@mrnull-mrnull:~/Desktop/ecowalls$ ng build --prod --aot=true Hash: 28c29744b9915dd78c34
Time: 20301ms chunk {0} polyfills.f77454f386e1728adda2.bundle.js (polyfills) 178 kB {4} [initial] [rendered] chunk {1} main.b46ba2bf68a6b3600bc3.bundle.js (main) 2.44 kB {3} [initial] [rendered] chunk {2} styles.d41d8cd98f00b204e980.bundle.css (styles) 69 bytes {4} [initial] [rendered] chunk {3} vendor.d1e70980d2f78b0ceaaa.bundle.js (vendor) 849 kB [initial] [rendered] chunk {4} inline.eb7d51cec64ef9b22661.bundle.js (inline) 0 bytes [entry] [rendered]

ERROR in ./src/main.ts Module not found: Error: Can't resolve './$$_gendir/app/app.module.ngfactory' in '/home/mrnull/Desktop/ecowalls/src' @ ./src/main.ts 3:0-74 @ multi ./src/main.ts

ERROR in ./src/environments/environment.ts Module build failed: TypeError: Cannot read property 'flags' of undefined at getSymbolLinks (/home/mrnull/Desktop/ecowalls/node_modules/typescript/lib/typescript.js:26080:23) at getTypeOfVariableOrParameterOrProperty (/home/mrnull/Desktop/ecowalls/node_modules/typescript/lib/typescript.js:29345:25) at checkVariableLikeDeclaration (/home/mrnull/Desktop/ecowalls/node_modules/typescript/lib/typescript.js:43177:41) at checkVariableDeclaration (/home/mrnull/Desktop/ecowalls/node_modules/typescript/lib/typescript.js:43233:20) at checkSourceElement (/home/mrnull/Desktop/ecowalls/node_modules/typescript/lib/typescript.js:45111:28) at Object.forEach (/home/mrnull/Desktop/ecowalls/node_modules/typescript/lib/typescript.js:1449:30) at checkVariableStatement (/home/mrnull/Desktop/ecowalls/node_modules/typescript/lib/typescript.js:43242:16) at checkSourceElement (/home/mrnull/Desktop/ecowalls/node_modules/typescript/lib/typescript.js:45080:28) at Object.forEach (/home/mrnull/Desktop/ecowalls/node_modules/typescript/lib/typescript.js:1449:30) at checkSourceFileWorker (/home/mrnull/Desktop/ecowalls/node_modules/typescript/lib/typescript.js:45198:20) at checkSourceFile (/home/mrnull/Desktop/ecowalls/node_modules/typescript/lib/typescript.js:45178:13) at getDiagnosticsWorker (/home/mrnull/Desktop/ecowalls/node_modules/typescript/lib/typescript.js:45242:17) at getDiagnostics (/home/mrnull/Desktop/ecowalls/node_modules/typescript/lib/typescript.js:45228:24) at Object.getEmitResolver (/home/mrnull/Desktop/ecowalls/node_modules/typescript/lib/typescript.js:25898:13) at /home/mrnull/Desktop/ecowalls/node_modules/typescript/lib/typescript.js:67689:69 at runWithCancellationToken (/home/mrnull/Desktop/ecowalls/node_modules/typescript/lib/typescript.js:67447:24) @ ./src/main.ts 2:0-57 @ multi ./src/main.ts

ERROR in ./src/$$_gendir async Module not found: Error: Can't resolve '/home/mrnull/Desktop/ecowalls/src/$$_gendir/app/admin/admin.module.ngfactory.ts' in '/home/mrnull/Desktop/ecowalls/src/$$_gendir' @ ./src/$$_gendir async @ ./~/@angular/core/@angular/core.es5.js @ ./src/main.ts @ multi ./src/main.ts

ERROR in ./src/$$_gendir async Module not found: Error: Can't resolve '/home/mrnull/Desktop/ecowalls/src/$$_gendir/app/admin/pages/pages.module.ngfactory.ts' in '/home/mrnull/Desktop/ecowalls/src/$$_gendir' @ ./src/$$_gendir async @ ./~/@angular/core/@angular/core.es5.js @ ./src/main.ts @ multi ./src/main.ts

ERROR in ./src/$$_gendir async Module not found: Error: Can't resolve '/home/mrnull/Desktop/ecowalls/src/$$_gendir/app/admin/pages/dashboard/dashboard.module.ngfactory.ts' in '/home/mrnull/Desktop/ecowalls/src/$$_gendir' @ ./src/$$_gendir async @ ./~/@angular/core/@angular/core.es5.js @ ./src/main.ts @ multi ./src/main.ts

ERROR in ./src/$$_gendir async Module not found: Error: Can't resolve '/home/mrnull/Desktop/ecowalls/src/$$_gendir/app/admin/login/login.module.ngfactory.ts' in '/home/mrnull/Desktop/ecowalls/src/$$_gendir' @ ./src/$$_gendir async @ ./~/@angular/core/@angular/core.es5.js @ ./src/main.ts @ multi ./src/main.ts mrnull@mrnull-mrnull:~/Desktop/ecowalls$ mrnull@mrnull-mrnull:~/Desktop/ecowalls$ ng build --aot Hash: e5cbdb3c184e874bd05b
Time: 16305ms chunk {0} polyfills.bundle.js, polyfills.bundle.js.map (polyfills) 178 kB {4} [initial] [rendered] chunk {1} styles.bundle.js, styles.bundle.js.map (styles) 10.5 kB {4} [initial] [rendered] chunk {2} main.bundle.js, main.bundle.js.map (main) 1.09 kB {3} [initial] [rendered] chunk {3} vendor.bundle.js, vendor.bundle.js.map (vendor) 849 kB [initial] [rendered] chunk {4} inline.bundle.js, inline.bundle.js.map (inline) 0 bytes [entry] [rendered]

ERROR in ./src/main.ts Module not found: Error: Can't resolve './$$_gendir/app/app.module.ngfactory' in '/home/mrnull/Desktop/ecowalls/src' @ ./src/main.ts 3:0-74 @ multi ./src/main.ts

ERROR in ./src/$$_gendir async Module not found: Error: Can't resolve '/home/mrnull/Desktop/ecowalls/src/$$_gendir/app/admin/admin.module.ngfactory.ts' in '/home/mrnull/Desktop/ecowalls/src/$$_gendir' @ ./src/$$_gendir async @ ./~/@angular/core/@angular/core.es5.js @ ./src/main.ts @ multi ./src/main.ts

ERROR in ./src/$$_gendir async Module not found: Error: Can't resolve '/home/mrnull/Desktop/ecowalls/src/$$_gendir/app/admin/pages/pages.module.ngfactory.ts' in '/home/mrnull/Desktop/ecowalls/src/$$_gendir' @ ./src/$$_gendir async @ ./~/@angular/core/@angular/core.es5.js @ ./src/main.ts @ multi ./src/main.ts

ERROR in ./src/$$_gendir async Module not found: Error: Can't resolve '/home/mrnull/Desktop/ecowalls/src/$$_gendir/app/admin/pages/dashboard/dashboard.module.ngfactory.ts' in '/home/mrnull/Desktop/ecowalls/src/$$_gendir' @ ./src/$$_gendir async @ ./~/@angular/core/@angular/core.es5.js @ ./src/main.ts @ multi ./src/main.ts

ERROR in ./src/$$_gendir async Module not found: Error: Can't resolve '/home/mrnull/Desktop/ecowalls/src/$$_gendir/app/admin/login/login.module.ngfactory.ts' in '/home/mrnull/Desktop/ecowalls/src/$$_gendir' @ ./src/$$_gendir async @ ./~/@angular/core/@angular/core.es5.js @ ./src/main.ts @ multi ./src/main.ts mrnull@mrnull-mrnull:~/Desktop/ecowalls$ mrnull@mrnull-mrnull:~/Desktop/ecowalls$ ng build --prod Hash: 826eade7e3d0c2da0c9b
Time: 19905ms chunk {0} polyfills.f77454f386e1728adda2.bundle.js (polyfills) 178 kB {4} [initial] [rendered] chunk {1} main.b46ba2bf68a6b3600bc3.bundle.js (main) 2.44 kB {3} [initial] [rendered] chunk {2} styles.d41d8cd98f00b204e980.bundle.css (styles) 69 bytes {4} [initial] [rendered] chunk {3} vendor.d1e70980d2f78b0ceaaa.bundle.js (vendor) 849 kB [initial] [rendered] chunk {4} inline.eb7d51cec64ef9b22661.bundle.js (inline) 0 bytes [entry] [rendered]

ERROR in ./src/main.ts Module not found: Error: Can't resolve './$$_gendir/app/app.module.ngfactory' in '/home/mrnull/Desktop/ecowalls/src' @ ./src/main.ts 3:0-74 @ multi ./src/main.ts

ERROR in ./src/environments/environment.ts Module build failed: TypeError: Cannot read property 'flags' of undefined at getSymbolLinks (/home/mrnull/Desktop/ecowalls/node_modules/typescript/lib/typescript.js:26080:23) at getTypeOfVariableOrParameterOrProperty (/home/mrnull/Desktop/ecowalls/node_modules/typescript/lib/typescript.js:29345:25) at checkVariableLikeDeclaration (/home/mrnull/Desktop/ecowalls/node_modules/typescript/lib/typescript.js:43177:41) at checkVariableDeclaration (/home/mrnull/Desktop/ecowalls/node_modules/typescript/lib/typescript.js:43233:20) at checkSourceElement (/home/mrnull/Desktop/ecowalls/node_modules/typescript/lib/typescript.js:45111:28) at Object.forEach (/home/mrnull/Desktop/ecowalls/node_modules/typescript/lib/typescript.js:1449:30) at checkVariableStatement (/home/mrnull/Desktop/ecowalls/node_modules/typescript/lib/typescript.js:43242:16) at checkSourceElement (/home/mrnull/Desktop/ecowalls/node_modules/typescript/lib/typescript.js:45080:28) at Object.forEach (/home/mrnull/Desktop/ecowalls/node_modules/typescript/lib/typescript.js:1449:30) at checkSourceFileWorker (/home/mrnull/Desktop/ecowalls/node_modules/typescript/lib/typescript.js:45198:20) at checkSourceFile (/home/mrnull/Desktop/ecowalls/node_modules/typescript/lib/typescript.js:45178:13) at getDiagnosticsWorker (/home/mrnull/Desktop/ecowalls/node_modules/typescript/lib/typescript.js:45242:17) at getDiagnostics (/home/mrnull/Desktop/ecowalls/node_modules/typescript/lib/typescript.js:45228:24) at Object.getEmitResolver (/home/mrnull/Desktop/ecowalls/node_modules/typescript/lib/typescript.js:25898:13) at /home/mrnull/Desktop/ecowalls/node_modules/typescript/lib/typescript.js:67689:69 at runWithCancellationToken (/home/mrnull/Desktop/ecowalls/node_modules/typescript/lib/typescript.js:67447:24) @ ./src/main.ts 2:0-57 @ multi ./src/main.ts

ERROR in ./src/$$_gendir async Module not found: Error: Can't resolve '/home/mrnull/Desktop/ecowalls/src/$$_gendir/app/admin/admin.module.ngfactory.ts' in '/home/mrnull/Desktop/ecowalls/src/$$_gendir' @ ./src/$$_gendir async @ ./~/@angular/core/@angular/core.es5.js @ ./src/main.ts @ multi ./src/main.ts

ERROR in ./src/$$_gendir async Module not found: Error: Can't resolve '/home/mrnull/Desktop/ecowalls/src/$$_gendir/app/admin/pages/pages.module.ngfactory.ts' in '/home/mrnull/Desktop/ecowalls/src/$$_gendir' @ ./src/$$_gendir async @ ./~/@angular/core/@angular/core.es5.js @ ./src/main.ts @ multi ./src/main.ts

ERROR in ./src/$$_gendir async Module not found: Error: Can't resolve '/home/mrnull/Desktop/ecowalls/src/$$_gendir/app/admin/pages/dashboard/dashboard.module.ngfactory.ts' in '/home/mrnull/Desktop/ecowalls/src/$$_gendir' @ ./src/$$_gendir async @ ./~/@angular/core/@angular/core.es5.js @ ./src/main.ts @ multi ./src/main.ts

ERROR in ./src/$$_gendir async Module not found: Error: Can't resolve '/home/mrnull/Desktop/ecowalls/src/$$_gendir/app/admin/login/login.module.ngfactory.ts' in '/home/mrnull/Desktop/ecowalls/src/$$_gendir' @ ./src/$$_gendir async @ ./~/@angular/core/@angular/core.es5.js @ ./src/main.ts @ multi ./src/main.ts mrnull@mrnull-mrnull:~/Desktop/ecowalls$ mrnull@mrnull-mrnull:~/Desktop/ecowalls$ npm uninstall --save @angular/cli npm WARN @angular/[email protected] requires a peer of @angular/[email protected] but none was installed. npm WARN [email protected] requires a peer of @types/chartist@^0.9.34 but none was installed. npm WARN optional SKIPPING OPTIONAL DEPENDENCY: [email protected] (node_modules/fsevents): npm WARN notsup SKIPPING OPTIONAL DEPENDENCY: Unsupported platform for [email protected]: wanted {"os":"darwin","arch":"any"} (current: {"os":"linux","arch":"x64"})

added 114 packages and removed 513 packages in 22.677s

╭─────────────────────────────────────╮ │ │ │ Update available 5.3.0 → 5.4.2 │ │ Run npm i -g npm to update │ │ │ ╰─────────────────────────────────────╯

mrnull@mrnull-mrnull:~/Desktop/ecowalls$ npm uninstall --save @angular/[email protected] npm WARN @angular/[email protected] requires a peer of @angular/[email protected] but none was installed. npm WARN [email protected] requires a peer of @types/chartist@^0.9.34 but none was installed. npm WARN optional SKIPPING OPTIONAL DEPENDENCY: [email protected] (node_modules/fsevents): npm WARN notsup SKIPPING OPTIONAL DEPENDENCY: Unsupported platform for [email protected]: wanted {"os":"darwin","arch":"any"} (current: {"os":"linux","arch":"x64"})

added 114 packages and updated 1 package in 8.754s mrnull@mrnull-mrnull:~/Desktop/ecowalls$

mrnull@mrnull-mrnull:~/Desktop/ecowalls$ ng build --prod Unable to find "@angular/cli" in devDependencies.

Please take the following steps to avoid issues: "npm install --save-dev @angular/cli@latest"

The "@angular/compiler-cli" package was not properly installed. Error: The "@angular/compiler-cli" package was not properly installed. at Object. (/usr/local/lib/node_modules/@angular/cli/node_modules/@ngtools/webpack/src/index.js:14:11) at Module._compile (module.js:573:30) at Object.Module._extensions..js (module.js:584:10) at Module.load (module.js:507:32) at tryModuleLoad (module.js:470:12) at Function.Module._load (module.js:462:3) at Module.require (module.js:517:17) at require (internal/module.js:11:18) at Object. (/usr/local/lib/node_modules/@angular/cli/tasks/eject.js:10:19) at Module._compile (module.js:573:30) at Object.Module._extensions..js (module.js:584:10) at Module.load (module.js:507:32) at tryModuleLoad (module.js:470:12) at Function.Module._load (module.js:462:3) at Module.require (module.js:517:17) at require (internal/module.js:11:18) mrnull@mrnull-mrnull:~/Desktop/ecowalls$ npm install --save @angular/[email protected]

[email protected] install /home/mrnull/Desktop/ecowalls/node_modules/node-sass node scripts/install.js

Cached binary found at /home/mrnull/.npm/node-sass/4.5.3/linux-x64-57_binding.node

[email protected] postinstall /home/mrnull/Desktop/ecowalls/node_modules/node-sass node scripts/build.js

Binary found at /home/mrnull/Desktop/ecowalls/node_modules/node-sass/vendor/linux-x64-57/binding.node Testing binary Binary is fine npm WARN @angular/[email protected] requires a peer of @angular/[email protected] but none was installed. npm WARN [email protected] requires a peer of @types/chartist@^0.9.34 but none was installed. npm WARN optional SKIPPING OPTIONAL DEPENDENCY: [email protected] (node_modules/fsevents): npm WARN notsup SKIPPING OPTIONAL DEPENDENCY: Unsupported platform for [email protected]: wanted {"os":"darwin","arch":"any"} (current: {"os":"linux","arch":"x64"})

  • @angular/[email protected] added 639 packages in 73.787s mrnull@mrnull-mrnull:~/Desktop/ecowalls$ mrnull@mrnull-mrnull:~/Desktop/ecowalls$ ng build --prod 10% building modules 5/7 modules 2 active ...ull/Desktop/ecowalls/src/polyfills.tsThe final argument to magicString.overwrite(...) should be an options object. See https://github.com/rich-harris/magic-string Hash: 035d3639ffc1f014a9e3
    Time: 39791ms chunk {0} 0.c35d0e1b7569c2893e26.chunk.js 1.49 MB {1} {2} {3} {5} [rendered] chunk {1} 1.057d4ed5fcf1aa98d22f.chunk.js 315 kB {0} {2} {3} {5} [rendered] chunk {2} 2.b440bf9d2b946fbcf9c1.chunk.js 46.2 kB {0} {1} {3} {5} [rendered] chunk {3} 3.933c65d31f4e2505e454.chunk.js 4.05 kB {0} {1} {2} {5} [rendered] chunk {4} polyfills.7bb85227ebb5989e30a5.bundle.js (polyfills) 178 kB {8} [initial] [rendered] chunk {5} main.7e296abc0250ef362bbf.bundle.js (main) 30 kB {7} [initial] [rendered] chunk {6} styles.d41d8cd98f00b204e980.bundle.css (styles) 69 bytes {8} [initial] [rendered] chunk {7} vendor.060a1b920b5f28e44455.bundle.js (vendor) 2.28 MB [initial] [rendered] chunk {8} inline.48edbf28269d5d8bfdd1.bundle.js (inline) 0 bytes [entry] [rendered] mrnull@mrnull-mrnull:~/Desktop/ecowalls$ ng build --prod --aot 10% building modules 5/7 modules 2 active ...ull/Desktop/ecowalls/src/polyfills.tsThe final argument to magicString.overwrite(...) should be an options object. See https://github.com/rich-harris/magic-string Hash: de71af4beaede60e81a3
    Time: 45164ms chunk {0} 0.c35d0e1b7569c2893e26.chunk.js 1.49 MB {1} {2} {3} {5} [rendered] chunk {1} 1.057d4ed5fcf1aa98d22f.chunk.js 315 kB {0} {2} {3} {5} [rendered] chunk {2} 2.b440bf9d2b946fbcf9c1.chunk.js 46.2 kB {0} {1} {3} {5} [rendered] chunk {3} 3.933c65d31f4e2505e454.chunk.js 4.05 kB {0} {1} {2} {5} [rendered] chunk {4} polyfills.7bb85227ebb5989e30a5.bundle.js (polyfills) 178 kB {8} [initial] [rendered] chunk {5} main.7e296abc0250ef362bbf.bundle.js (main) 30 kB {7} [initial] [rendered] chunk {6} styles.d41d8cd98f00b204e980.bundle.css (styles) 69 bytes {8} [initial] [rendered] chunk {7} vendor.060a1b920b5f28e44455.bundle.js (vendor) 2.28 MB [initial] [rendered] chunk {8} inline.48edbf28269d5d8bfdd1.bundle.js (inline) 0 bytes [entry] [rendered] mrnull@mrnull-mrnull:~/Desktop/ecowalls$

alirezaahmadibeni avatar Sep 15 '17 14:09 alirezaahmadibeni

Running angular 4.0.0

upgrading @angular/cli to v1.2.5 with npm install --save @angular/[email protected]

offroadkev avatar Oct 02 '17 06:10 offroadkev

https://stackoverflow.com/questions/42718095/module-not-found-error-cant-resolve-gendir-app-app-module-ngfactory

This was the winner for me...specifically the ncu part

blapsley avatar Oct 05 '17 18:10 blapsley

check if there is an uppercase letter in your module directory path

mtivlishvili avatar Oct 17 '17 05:10 mtivlishvili


Go into node_modules/webpack/ directory then install [email protected] work for me.

problem

There is no 'enhanced-resolve' package in my package.json, and not in the root of the node_modules. So I run yarn add [email protected] --dev, then ng build --prod still not work. then I checked package list by run yarn list, I find [email protected] in package.json from @angular-cli/webpack but [email protected] installed in the webpack. So I go into the webpack directory and force install [email protected], then it's work for me.

wuyuchang avatar Oct 26 '17 09:10 wuyuchang

After trying different permutations of different versions of everything, I FINALLY got this figured out and I couldn't believe the reason. A while back, in order to get my dev build/serve working, I had to add **/*.d.ts to the include array in my tsconfig, otherwise I got all kinds of "cannot find name" errors. I did not realize that the reason that was happening was because tsconfig.app.json was generated by the CLI with an empty types array, so even though the base tsconfig.json specified the correct "typeRoots" directory, the empty types array was causing the errors. Even though adding **/*.d.ts to the include array fixed dev build/serve errors, it was the reason for the prod build error in this issue. Removing that and the empty types array in tsconfig.app.json allowed me to build both dev and prod successfully. Hopefully this will help somebody else.

IRCraziestTaxi avatar Oct 26 '17 14:10 IRCraziestTaxi

use @angular/[email protected] solved my problem

finalxcode avatar Nov 07 '17 01:11 finalxcode

I am facing same issue. I have angular cli 1.5.0

Angular CLI: 1.5.0 Node: 8.9.0 OS: darwin x64 Angular: 5.0.0 ... animations, common, compiler, core, forms, http ... language-service, platform-browser, platform-browser-dynamic ... platform-server, router

@angular/cli: 1.5.0 @angular/compiler-cli: 4.4.6 @angular/tsc-wrapped: 4.4.6 @angular-devkit/build-optimizer: 0.0.32 @angular-devkit/core: 0.0.20 @angular-devkit/schematics: 0.0.35 @ngtools/json-schema: 1.1.0 @ngtools/webpack: 1.8.0 @schematics/angular: 0.1.0 typescript: 2.6.1 webpack: 3.8.1

mrusmanali avatar Nov 07 '17 07:11 mrusmanali

Updating your packages, especially Angular CLI and Webpack fixed the problem for me. Try that and see the difference. Am using "@angular/cli": "^1.5.0", and "webpack": "^3.8.1"

cymushier avatar Nov 07 '17 14:11 cymushier

I had the same problem, just followed official document to update to the last version of angular-cli solved the problem. There are two steps.

To update Angular CLI to a new version, you must update both the global package and your project's local package.

Global package:

npm uninstall -g @angular/cli
npm cache clean
# if npm version is > 5 then use `npm cache verify` to avoid errors (or to avoid using --force)
npm install -g @angular/cli@latest

Local project package:

rm -rf node_modules dist # use rmdir /S/Q node_modules dist in Windows Command Prompt; use rm -r -fo node_modules,dist in Windows PowerShell
npm install --save-dev @angular/cli@latest
npm install

Ref: https://github.com/angular/angular-cli#updating-angular-cli

OnlyBelter avatar Nov 08 '17 04:11 OnlyBelter

Hi all,

After run of "ng build --prod" I have this issue: "ERROR in ./src/main.ts Module not found: Error: Can't resolve './$$_gendir/app/app.module.ngfactory'"

I have Angular CLI 1.5.0. My main.ts:

import { platformBrowserDynamic } from '@angular/platform-browser-dynamic'; import { enableProdMode } from '@angular/core';

import { AppModule } from './app/app.module';

enableProdMode(); platformBrowserDynamic().bootstrapModule(AppModule);

what is wrong here, how to fix this issue?

filip88etf avatar Nov 09 '17 09:11 filip88etf

@filip88etf . I had a similar issue and the cause (in my case) was that I had upgraded typescript to a non-supported version. By supported version I mean supported by the angular framework version I was currently running which happened to be 4.4.6 . The current supported typescript version for 4.4.6 is 2.4.2.

IgorWolbers avatar Nov 10 '17 19:11 IgorWolbers

I created a new project using angular-cli 1.5.0 and copied my existing code to that project. Its not a solution but i don't want to put more time in inspecting whats wrong with compiler.

mrusmanali avatar Nov 11 '17 05:11 mrusmanali

There were two ways I could fix this- 1] Updating typescript to latest npm install --save typescript@latest 2] make the aot flag false ng build --prod --aot=false

kapilgorve avatar Nov 20 '17 14:11 kapilgorve

I had the same error as it was just a silly mistake. I installed third party libraries without --save..So at the time of build it was not able to find the package in package.json( may be this is the reason i guess). Hope this will benefit someone.

renilbabu03 avatar Nov 21 '17 05:11 renilbabu03

ng build --prod --aot false

This solved my problem.

It is not a solution though.

Later,

  • I updated the cli again
  • Followed the error messages and fixed them Now there's no complain

ariful19 avatar Nov 23 '17 09:11 ariful19

Everybody, please note that while using --aot false is a workaround that might allow you to build, you do lose the benefits of AOT compilation, so you should still be searching for a real solution.

IRCraziestTaxi avatar Nov 27 '17 14:11 IRCraziestTaxi