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

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

zxhfighter avatar Jul 25 '17 02:07 zxhfighter

@angular/cli: 1.2.4 fix the problem

tianyuanzhonglu avatar Jul 25 '17 03:07 tianyuanzhonglu

@angular/cli: 1.2.4 fix the problem

abhi901abhi avatar Jul 25 '17 06:07 abhi901abhi

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?

flauc avatar Jul 25 '17 07:07 flauc

@angular/cli: 1.2.4 doesn't fix the problem for me. npm install [email protected] fixes it temporarily

eydrian avatar Jul 25 '17 08:07 eydrian

@angular/cli: 1.2.4 didn't fix it. enhanced-resolve: 3.3.0 fixes it.

BaimosTechnologies avatar Jul 25 '17 08:07 BaimosTechnologies

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.

flauc avatar Jul 25 '17 08:07 flauc

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.

swordman1205 avatar Jul 25 '17 09:07 swordman1205

https://github.com/angular/angular-cli/commit/dbc7959503604af077c0fa1ada4d60643e5ab399 Fixes it by pinning [email protected]

mhamel06 avatar Jul 25 '17 12:07 mhamel06

Fixed by [email protected] on Mac

vcorr avatar Jul 25 '17 12:07 vcorr

Why does enhanced-resolve fix it though? (yes, it fixes it for me too, but I want to know why)

maychan111 avatar Jul 25 '17 16:07 maychan111

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 !

fkolar avatar Jul 25 '17 18:07 fkolar

@angular/cli: 1.2.4 fix the problem for me whereas installing enhanced-resolve didn't

AhsanAyaz avatar Jul 25 '17 21:07 AhsanAyaz

Came across the issue, neither the emergency release or enhanced resolve have solved the problem until now :(

jotatoledo avatar Jul 25 '17 21:07 jotatoledo

I just updated my @angular/cli version to 1.3.0-rc.1 and that fixed it for me. @jotatoledo, possibly try that?

thomaswmanion avatar Jul 25 '17 21:07 thomaswmanion

Ill try, Im currently using the default project of @1.2.4 with ng build --prod with no luck

jotatoledo avatar Jul 25 '17 21:07 jotatoledo

My issue is related to yarn install see https://github.com/angular/angular-cli/issues/7113#issuecomment-317531801

jotatoledo avatar Jul 25 '17 21:07 jotatoledo

I am using "@ngtools/webpack": "1.5.3" and can confirm the enhanced-resolve workaround did not solve my issue.

patrickhousley avatar Jul 25 '17 22:07 patrickhousley

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

jotatoledo avatar Jul 25 '17 22:07 jotatoledo

I am still having the same problem with "@ngtools/webpack": "^1.6.0-rc.1"

patrickhousley avatar Jul 25 '17 22:07 patrickhousley