question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

--aot build error: ERROR in ./src/main.ts Module not found

See original GitHub issue

Issue Description

$ng serve with build param --aot has error:

ERROR in ./src/main.ts Module not found ...

However, build is successful using plain ng serve or ng serve --prod.

OS?

Mac OSX Sierra

Versions.

angular-cli: 1.0.0-beta.26 node: 7.2.1 os: darwin x64 @angular/common: 2.4.4 @angular/compiler: 2.4.4 @angular/core: 2.4.4 @angular/forms: 2.4.4 @angular/http: 2.4.4 @angular/platform-browser: 2.4.4 @angular/platform-browser-dynamic: 2.4.4 @angular/router: 3.4.4 @angular/compiler-cli: 2.4.4

Repro steps.

N.A. default Angular-cli

The log given by the failure.

ERROR in ./src/main.ts
Module not found: Error: Can't resolve './$$_gendir/app/app.module.ngfactory' in '/Users/home/Desktop/web_2/Dev/00_Active_Dev/src'
 @ ./src/main.ts 4:0-74
 @ multi webpack-dev-server/client?http://localhost:4200/ ./src/main.ts

ERROR in ./~/@angular/core/src/linker/system_js_ng_module_factory_loader.js
Module not found: Error: Can't resolve '/Users/home/Desktop/web_2/Dev/00_Active_Dev/src/$$_gendir' in '/Users/home/Desktop/web_2/Dev/00_Active_Dev/node_modules/@angular/core/src/linker'
 @ ./~/@angular/core/src/linker/system_js_ng_module_factory_loader.js 71:15-36 87:15-102
 @ ./~/@angular/core/src/linker.js
 @ ./~/@angular/core/src/core.js
 @ ./~/@angular/core/index.js
 @ ./src/main.ts
 @ multi webpack-dev-server/client?http://localhost:4200/ ./src/main.ts

Issue Analytics

  • State:closed
  • Created 7 years ago
  • Reactions:3
  • Comments:7 (2 by maintainers)

github_iconTop GitHub Comments

3reactions
filipesilvacommented, Jan 26, 2017

If you can provide us with a repo we can look at, we might be able to help. The error by itself doesn’t tell me much though.

1reaction
sw-tt-tarunvarmacommented, Feb 28, 2017

Ok. I got the solutions please restart your app. if you delete any existing module in your app.

Read more comments on GitHub >

github_iconTop Results From Across the Web

2 Answers - 2 - Stack Overflow
Angular 4 error - ERROR in ./src/main.ts Module not found: Error: Can't resolve './$$_gendir/app/app.module.ngfactory'.
Read more >
MDB Angular Pro - 4.3.1 does not build in the -prod mode
4 - Forth run of ng build -prod brings CLI error: ERROR in ./src/main.ts Module not found: Error: Can't resolve './$$_gendir/app/app.module.ngfactory' in ...
Read more >
Can't build my project : r/Angular2 - Reddit
If I try to run ng build --prod or ng build --aot, ... src/app/app.module.ts Module not found: Error: Can't resolve '../. ... src/main.ts....
Read more >
Angular 6 AOT build fails on Kendo UI Angular modules - Telerik
ERROR in ./src/app/foo/bar/bar. · Module not found: Error: Can't resolve '@package-author/package. · resolve '@package-author/package. · Parsed ...
Read more >
field 'browser' doesn't contain a valid alias configuration angular
assets/app/main.aot.ts' }, output: { path: path.resolve(__dirname + ... src/app/employee/employee.component.ts Module not found: Error: Can't resolve '.
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found