2
votes

I'm working on angular-cli. I got following errors.

ERROR in ./src/main.ts Module not found: Error: Can't resolve './$$_gendir/app/app.module.ngfactory' in 'D:\material\matapp\src' @ ./src/main.ts 3:0-74 @ multi ./src/main.ts

My main.ts file:

import { enableProdMode } from '@angular/core'; 
import { platformBrowserDynamic } from '@angular/platform-browser-dynamic'; 
import { AppModule } from './app/app.module'; 
import { environment } from './environments/environment'; 

if (environment.production) { 
    enableProdMode(); 
} 
platformBrowserDynamic().bootstrapModule(AppModule);

Kindly help me to resolve the issue.PFAenter image description here

5
My main.ts file is import { enableProdMode } from '@angular/core'; import { platformBrowserDynamic } from '@angular/platform-browser-dynamic'; import { AppModule } from './app/app.module'; import { environment } from './environments/environment'; if (environment.production) { enableProdMode(); } platformBrowserDynamic().bootstrapModule(AppModule); - Siva Unique
Which angular-cli version, you are using? - Avnesh Shakya
@angular/cli: 1.2.0 - Siva Unique
Not sure, but check your package.json where check version for "enhanced-resolve": "^3.4.1", - Avnesh Shakya
@avnesh shakya. not available - Siva Unique

5 Answers

8
votes

The real problem here is that the Angular CLI error messages are rubbish. This is how I solved it:

npm install [email protected]

I found the solution a long, long way down this page: https://github.com/angular/angular-cli/issues/7113

1
votes

I had this same problem. I resolved by upgrading the angular cli to version 1.2.6.

1
votes

Change "@angular/cli": "1.0.0", from package.json to "@angular/cli": "1.2.4"

Make sure after changing from 1.0.0 ver to 1.2.4 to do npm install before you ng build ...

0
votes

try this

ng build -prod --aot=false

enter image description here

0
votes

I had same issue and fixed it by deleting node_module and run npm install.