Skip to content

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

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
pageii opened this issue Jan 26, 2017 · 7 comments
Closed

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

pageii opened this issue Jan 26, 2017 · 7 comments
Labels
needs: repro steps We cannot reproduce the issue with the information given

Comments

@pageii
Copy link

pageii commented Jan 26, 2017

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
@Meligy
Copy link
Contributor

Meligy commented Jan 26, 2017

Can you please provide the source for the app module? Or even better a small project that shows this problem happening?

Also, do you have the same issue if you use NPM 6.x?

Thanks a lot.

@luisabreu
Copy link

Just finished fixing one of these...In my case, someone had copied one component to another folder (in a different module). So, I've ended with:
/drivers/driver.component.ts (included in driver.module.ts)
...
/user/driver.component.ts (no included in any module)~

Interestingly, the error msg said that /drivers/driver.component.ts wasn't associated to any module (instead of /user/drivers,component.ts)...

@filipesilva
Copy link
Contributor

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.

@filipesilva filipesilva added the needs: repro steps We cannot reproduce the issue with the information given label Jan 26, 2017
@sw-tt-tarunvarma
Copy link

I have deleted my existing module from angular js 2 then it will be raise this kind of error.

@sw-tt-tarunvarma
Copy link

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

@pageii
Copy link
Author

pageii commented Mar 17, 2017

Thank you for your wonderful responses and fixes.

In NG4 beta+ && Node 7+. aot runs splendidly including lazily-loaded modules. The performance is phenomenal (see below for versions used). Can't image how much better it can get when I top it up with Service workers and Universal.

@angular/cli: 1.0.0-beta.31 (NG4 is going into RC4 as of writing)
node: 7.4.0
os: darwin x64
@angular/common: 4.0.0-beta.7
@angular/compiler: 4.0.0-beta.7
@angular/core: 4.0.0-beta.7
@angular/forms: 4.0.0-beta.7
@angular/http: 4.0.0-beta.7
@angular/material: 2.0.0-beta.2
@angular/platform-browser: 4.0.0-beta.7
@angular/platform-browser-dynamic: 4.0.0-beta.7
@angular/router: 4.0.0-beta.7
@angular/cli: 1.0.0-beta.31
@angular/compiler-cli: 4.0.0-beta.7

@pageii pageii closed this as completed Mar 17, 2017
@angular-automatic-lock-bot
Copy link

This issue has been automatically locked due to inactivity.
Please file a new issue if you are encountering a similar or related problem.

Read more about our automatic conversation locking policy.

This action has been performed automatically by a bot.

@angular-automatic-lock-bot angular-automatic-lock-bot bot locked and limited conversation to collaborators Sep 6, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
needs: repro steps We cannot reproduce the issue with the information given
Projects
None yet
Development

No branches or pull requests

5 participants