ng build -prod Module not found: Error: Can't resolve './$$_gendir/app/app.module.ngfactory'
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.
I'v that problem too, use ng new create a project and use ng build --prod,and it fails.
ERROR in ./src/main.ts
Module not found: Error: Can't resolve './$$_gendir/app/app.module.ngfactory' in '/Users/baidu/apps/device-monitor/src'
@ ./src/main.ts 3:0-74
@ multi ./src/main.ts
@angular/cli: 1.1.3 node: 6.9.5 os: darwin x64 @angular/animations: 4.3.1 @angular/common: 4.3.1 @angular/compiler: 4.3.1 @angular/core: 4.3.1 @angular/forms: 4.3.1 @angular/http: 4.3.1 @angular/platform-browser: 4.3.1 @angular/platform-browser-dynamic: 4.3.1 @angular/router: 4.3.1 @angular/cli: 1.1.3 @angular/compiler-cli: 4.3.1 @angular/language-service: 4.3.1
@angular/cli: 1.2.4 fix the problem
@angular/cli: 1.2.4 fix the problem
I'm getting this error but I'm not using @angular/cli.
npm install [email protected]
Does fix it temporarily, but does someone know how angular/cli fixed it?
@angular/cli: 1.2.4 doesn't fix the problem for me. npm install [email protected] fixes it temporarily
@angular/cli: 1.2.4 didn't fix it. enhanced-resolve: 3.3.0 fixes it.
For some reason enhanced-resolve: 3.3.0 fixes it for my on windows, but not on linux. It's the same version of npm and node on both machines.
Any help is greatly appreciated.
Same issue. Here is my environment.
@angular/cli: 1.0.3 node: 6.11.1 os: darwin x64 @angular/common: 4.3.1 @angular/compiler: 4.3.1 @angular/core: 4.3.1 @angular/forms: 4.3.1 @angular/http: 4.3.1 @angular/platform-browser: 4.3.1 @angular/platform-browser-dynamic: 4.3.1 @angular/router: 4.3.1 @angular/cli: 1.0.3 @angular/compiler-cli: 4.3.1
enhanced-resolve: 3.3.0 fixed my issue.
https://github.com/angular/angular-cli/commit/dbc7959503604af077c0fa1ada4d60643e5ab399 Fixes it by pinning [email protected]
Fixed by [email protected] on Mac
Why does enhanced-resolve fix it though? (yes, it fixes it for me too, but I want to know why)
Maybe this issue should be reoped ?
regards to enhanced-resolve They just upgraded to new library I guess. Its dependency for @ngtools.
Before was it was 3.3.0
└─┬ @angular/[email protected]
├─┬ @ngtools/[email protected]
│ └── [email protected]
├── [email protected]
But 3.3.0 resolved my problem as well !
@angular/cli: 1.2.4 fix the problem for me whereas installing enhanced-resolve didn't
Came across the issue, neither the emergency release or enhanced resolve have solved the problem until now :(
I just updated my @angular/cli version to 1.3.0-rc.1 and that fixed it for me. @jotatoledo, possibly try that?
Ill try, Im currently using the default project of @1.2.4 with ng build --prod with no luck
My issue is related to yarn install see https://github.com/angular/angular-cli/issues/7113#issuecomment-317531801
I am using "@ngtools/webpack": "1.5.3" and can confirm the enhanced-resolve workaround did not solve my issue.
1.3.0.rc-1 and 1.2.4 should fix the issue without trick install of enhanced -resolve, but you need to install them with npm. For yarn users there is another problem apparently
I am still having the same problem with "@ngtools/webpack": "^1.6.0-rc.1"