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 had the the same problem. I fixed it by using ng-packagr v3.0.3 instead of v2.4.5 when building the npm-package.

affilnost avatar Sep 26 '18 19:09 affilnost

+1 linux mint

ERROR in this._input.charCodeAt is not a function

ERROR in ./src/main.ts
Module not found: Error: Can't resolve './$$_gendir/app/app.module.ngfactory' in '/home/vs/Work/GoFactTables/GoFactFrontend/src'
 @ ./src/main.ts 5:0-74
 @ multi ./src/main.ts

I have the same issue which you are facing . have you find any solution if yes then please suggest me.

rameshpraja avatar Oct 17 '18 09:10 rameshpraja

I know this call is closed, but its the first link I found when googling, so here is my solution.

ERROR in ./src/main.server.ts
Module not found: Error: Can't resolve './app/app.server.module.ngfactory'

Using Angular 7.1.4, reason was I enabledIvy after upgrading from 6 to 7.

"angularCompilerOptions": {
  "enableIvy": true
} 

Removed the flag and all was good.

Ivy is still in Beta and should not be used in production see issue 21706

jan1za avatar Dec 28 '18 10:12 jan1za

For me it was having "rootDir" in my tsconfig.json ... (I needed to remove it)

cyraid avatar Feb 07 '19 22:02 cyraid

This command is 100% work for solving this problem. npm install [email protected]

For me it worked with this solution.

omesquita avatar Feb 13 '19 20:02 omesquita

/ \ _ __ __ _ _ | | __ _ _ __ / | | | | / △ \ | ' \ / _ | | | | |/ _ | '| | | | | | | / ___ | | | | (| | || | | (| | | | || | | | // __| ||_, |_,||_,|| _||| |___/ @angular/cli: 1.0.1 node: 6.14.3 os: linux x64 @angular/common: 4.3.5 @angular/compiler: 4.3.5 @angular/core: 4.3.5 @angular/forms: 4.3.5 @angular/http: 4.3.5 @angular/platform-browser: 4.3.5 @angular/platform-browser-dynamic: 4.3.5 @angular/router: 4.3.5 @angular/cli: 1.0.1 @angular/compiler-cli: 4.3.5

and this is the error

ERROR in ./src/main.ts Module not found: Error: Can't resolve './$$_gendir/app/app.module.ngfactory' in '/var/www/html/v2site/lite_frontend/src' @ ./src/main.ts 5:0-74 @ multi ./src/main.ts

please suggest solution asap

ervivekmahajan avatar Feb 14 '19 06:02 ervivekmahajan

@ervivekmahajan please read all the comments asap

darkguy2008 avatar Feb 14 '19 08:02 darkguy2008

Still having this issue. All the proposed solutions don't work: no absolute paths, rootDir doesnt exist, aot=false doesn't work since buildOptimizer requires AOT. Using Angular 7.2. Any help?

andrewantar avatar Mar 18 '19 22:03 andrewantar

I still have this issue as well. I checked the various solutions but none worked for me.

AntJanus avatar Apr 18 '19 17:04 AntJanus

s/@types/googlemaps/index.d.ts (1977,5): Duplicate identifier 'OK'. u/node_modules/@types/googlemaps/index.d.ts (2124,33): Duplicate identifier 'DEFAULT'. plz help

sachingeniushub avatar May 10 '19 08:05 sachingeniushub

@WiL-dev : I can confirm it works fine on 1.0.0-rc1. Thanks!

Hello

i am using same version but not working. can help how to fixed this

Version:

@angular/cli: 1.0.0-rc.1 node: 8.11.4 os: win32 x64 @angular/common: 2.4.10 @angular/compiler: 2.4.10 @angular/core: 2.4.10 @angular/forms: 2.4.10 @angular/http: 2.4.10 @angular/platform-browser: 2.4.10 @angular/platform-browser-dynamic: 2.4.10 @angular/router: 3.4.10 @angular/cli: 1.0.0-rc.1 @angular/compiler-cli: 2.4.10

Error ERROR in ./src/main.ts Module not found: Error: Can't resolve './$$_gendir/app/app.module.ngfactory' in 'C:\Users\gazala\Desktop\GCDB_Workspace\GCDB6-Portal-Final\src' @ ./src/main.ts 5:0-74 @ multi ./src/main.ts

Gajendrasinh avatar May 13 '19 04:05 Gajendrasinh

This command is 100% work for solving this problem. npm install [email protected]

This solution is not work.

This is my package version

Angular CLI: 1.7.4 Node: 8.11.4 OS: win32 x64 Angular: 2.4.10 ... common, compiler, compiler-cli, core, forms, http ... platform-browser, platform-browser-dynamic

@angular/cli: 1.7.4 @angular/router: 3.4.10 @angular/tsc-wrapped: 0.5.2 @angular-devkit/build-optimizer: 0.3.2 @angular-devkit/core: 0.3.2 @angular-devkit/schematics: 0.3.2 @ngtools/json-schema: 1.2.0 @ngtools/webpack: 1.10.2 @schematics/angular: 0.3.2 @schematics/package-update: 0.3.2 typescript: 2.9.2 webpack: 3.11.0

Gajendrasinh avatar May 16 '19 07:05 Gajendrasinh

image

angular 7 to 8 update face issue

kannanwst avatar Jun 11 '19 07:06 kannanwst

  1. remove node_modules dir.
  2. execute 'npm cache clean --force'.
  3. delete package-lock.json. after these. aot is success! hope help u.

yy7054wyq5 avatar Jul 25 '19 02:07 yy7054wyq5

This command is 100% work for solving this problem. npm install [email protected]

worked for me too

tindalida avatar Jul 29 '19 07:07 tindalida

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.