Angular-cli: ng build -prod Module not found: Error: Can't resolve './$$_gendir/app/app.module.ngfactory'

Created on 9 Feb 2017  ·  156Comments  ·  Source: angular/angular-cli

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\ThaniriDesktop\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.

Most helpful comment

Instead of use
ng build --prod
use
ng build --env=prod

UPDATE

As many of us (thx) have mention, this doesn't build with aot so, it's the same that the plain ng build at the end (as says @adessilly
ng build --env=prod : replace environment.ts by environment.prod.ts, but it's a simple ng build.
ng build --prod : improved build with aot + environment.prod.ts replacement (before, it was ng build --prod --aot)
)

The most easy workaround (at least for me), was to create a new whole project with the last Angular CLI version, and moves the src folder. It's no straight forward, so please read the migration guide and don't forget to make a backup before.

Migration guide

All 156 comments

Having the same failure on both linux and windows platforms.

ERROR in Cannot read property 'map' of undefined

ERROR in ./src/main.ts
Module not found: Error: Can't resolve './$$_gendir/app/helix-app.module.ngfactory' in 'C:\Users\agarbutt\WebstormProjects\helix-ui\src'
 @ ./src/main.ts 3:0-85
 @ multi ./src/main.ts

main.ts

import {platformBrowserDynamic} from "@angular/platform-browser-dynamic";
import {enableProdMode} from "@angular/core";
import {environment} from "./environments/environment";
import {HelixAppModule} from "./app/";

if (environment.production) {
  enableProdMode();
}

platformBrowserDynamic()
  .bootstrapModule(HelixAppModule)
  .catch(err => console.error(err));

+1

+1 (on Windows 10 64bits)

+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

This may or may not be helpful but I have noticed that the first error seems to be the primary cause and the Module not found error is generic and will happen any time something breaks the aot build.

In my case I was getting the following any time I had an empty scss file:

ERROR in Child compilation failed:
Module build failed: No input specified: provide a file name or a source string to process:
[object Object]

ERROR in ./src/main.ts
Module not found: Error: Can't resolve './$$_gendir/app/app.module.ngfactory' in '/Users/mhamel/Development/blispay/blispay-ui2/src'
 @ ./src/main.ts 4:0-76
 @ multi ./src/main.ts

As soon as I fixed the first error, the Module not found error resolved itself. From that, I would expect @IlyaSurmay and @agarbutt each have different project specific bugs. (Possibly aot compiler related)

Can you see if the --verbose flag gives you any more information about the error?

http://pastebin.com/Hmrs0Kh7

CTRL+F the document for 'was generated' to find out what command I used:
ng build -prod --verbose > aFile.txt
ng build -prod --verbose

If you want to try it yourself please clone this repo:
https://github.com/thaniri/angularPortfolio

I have no empty .scss files, and even if I attempt to add something to styles.css in the src folder, I get the same error.

The same thing happens for me. No error other than:

ERROR in ./src/client.aot.ts Module not found: Error: Can't resolve './$$_gendir/browser.module.ngfactory' in '/home/pradej/Projekty/site-backoffice/src' @ ./src/client.aot.ts 2:0-75

I had to make a separate, plain client entry point for AOT, but it still doesn't work.

import { enableProdMode } from '@angular/core';
import { platformBrowserDynamic } from '@angular/platform-browser-dynamic';

import { MainModule } from './browser.module';

enableProdMode();

platformBrowserDynamic().bootstrapModule(MainModule);

OS: Fedora 25 x64

Also, if that's helpful, my project is using Universal, but AOT is used for client only.

I think it might be ngc. I cannot make it generate anything even when
running it directly.

16.02.2017 4:43 PM "Ilya Surmay" notifications@github.com napisał(a):

+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


You are receiving this because you commented.
Reply to this email directly, view it on GitHub
https://github.com/angular/angular-cli/issues/4551#issuecomment-280366544,
or mute the thread
https://github.com/notifications/unsubscribe-auth/ATNfaOp3L5J0yev2EYWiQmUg8iZvNSx_ks5rdG6GgaJpZM4L7u-Y
.

Same error when I upgraded to 4.0.0-beta.8. Previous version 4.0.0-beta.7 doesn't have this failure.

This is how I fixed my issues with the last version of angular-cli :
https://medium.com/@isaacplmann/making-your-angular-2-library-statically-analyzable-for-aot-e1c6f3ebedd5#.n4b11wso1

With the last version of angular-cli, ng build --prod seems to compile with --aot by default : I didn't know there was good practices to make project working with...

See next. I found a solution for me.

I hope this helps.

Similar problem with 1.0.0-rc1 on Windows. Running ng build --prod gives

ERROR in Error encountered resolving symbol values statically. Could not resolve events relative to C:/Projects/craft-ng/editor/node_modules/blocking-proxy/built/lib/webdriver_commands.d.ts., resolving
symbol WebDriverCommand in C:/Projects/craft-ng/editor/node_modules/blocking-proxy/built/lib/webdriver_commands.d.ts

ERROR in ./src/main.ts
Module not found: Error: Can't resolve './$$_gendir/app/app.module.ngfactory' in 'C:\Projects\craft-ng\editor\src'
@ ./src/main.ts 4:0-74
@ multi ./src/main.ts

ng build --prod --aot=false executes without problems.

This issue was closed, any advice for people still sufferring from this error?

Just to tell everyone: I eventually dropped @ngtools/webpack completely from my project and replaced it with @ultimate/aot-loader. AOT now finally works.

Instead of use
ng build --prod
use
ng build --env=prod

UPDATE

As many of us (thx) have mention, this doesn't build with aot so, it's the same that the plain ng build at the end (as says @adessilly
ng build --env=prod : replace environment.ts by environment.prod.ts, but it's a simple ng build.
ng build --prod : improved build with aot + environment.prod.ts replacement (before, it was ng build --prod --aot)
)

The most easy workaround (at least for me), was to create a new whole project with the last Angular CLI version, and moves the src folder. It's no straight forward, so please read the migration guide and don't forget to make a backup before.

Migration guide

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

@WiL-dev - I'm not sure ng build --env-prod builds with aot like ng build --prod does. If I run ng build --env=prod the tool generates the same size for my output as ng build --env=dev does. In addition running ng build --env=prod --aot=true gnerates the same error that I was origially getting. Unexpected value 'null' exported by the module 'MyModule' && down the stack Error: Can't resolve './$$_gendir/app/app.module.ngfactory'

This leads me to suspect that the cli tool is fine and it's my app that needs some updates before it can be --aot compiled.

Something I'll look into when I have a bit of time.

unresolved, --env produces not the same output as --prod

@russkayairina it's a normal behavior :
ng build --env=prod : replace environment.ts by environment.prod.ts, but it's a simple ng build.
ng build --prod : improved build with aot + environment.prod.ts replacement (before, it was ng build --prod --aot).

To make your project working with aot, follow these steps :
https://medium.com/@isaacplmann/making-your-angular-2-library-statically-analyzable-for-aot-e1c6f3ebedd5#.n4b11wso1

This is still a problem. It happens even with the newly created project from ng new!

Full output:

d:\Temp\cli>ng -v
    _                      _                 ____ _     ___
   / \   _ __   __ _ _   _| | __ _ _ __     / ___| |   |_ _|
  / △ \ | '_ \ / _` | | | | |/ _` | '__|   | |   | |    | |
 / ___ \| | | | (_| | |_| | | (_| | |      | |___| |___ | |
/_/   \_\_| |_|\__, |\__,_|_|\__,_|_|       \____|_____|___|
               |___/
@angular/cli: 1.0.0
node: 6.9.1
os: win32 x64

d:\Temp\cli>ng new cli-test
installing ng
  create .editorconfig
  create README.md
  create src\app\app.component.css
  create src\app\app.component.html
  create src\app\app.component.spec.ts
  create src\app\app.component.ts
  create src\app\app.module.ts
  create src\assets\.gitkeep
  create src\environments\environment.prod.ts
  create src\environments\environment.ts
  create src\favicon.ico
  create src\index.html
  create src\main.ts
  create src\polyfills.ts
  create src\styles.css
  create src\test.ts
  create src\tsconfig.app.json
  create src\tsconfig.spec.json
  create src\typings.d.ts
  create .angular-cli.json
  create e2e\app.e2e-spec.ts
  create e2e\app.po.ts
  create e2e\tsconfig.e2e.json
  create .gitignore
  create karma.conf.js
  create package.json
  create protractor.conf.js
  create tsconfig.json
  create tslint.json
Successfully initialized git.
Installing packages for tooling via npm.
Installed packages for tooling via npm.
Project 'cli-test' successfully created.

d:\Temp\cli>cd cli-test

d:\Temp\cli\cli-test>ng build --prod --env=prod
Hash: 0bfde11b73d9b21b101b
Time: 6189ms
chunk    {0} polyfills.7fd9b43f06a670d8299a.bundle.js (polyfills) 158 kB {3} [initial] [rendered]
chunk    {1}  (styles) 1.72 kB {3} [initial] [rendered]
chunk    {2} main.e1bb4892ef6fedc166cd.bundle.js (main) 806 kB [initial] [rendered]
chunk    {3} inline.65cd0835207a2ba3e811.bundle.js (inline) 0 bytes [entry] [rendered]

ERROR in E:/Temp/cli/cli-test/src/main.ts
Module not found: Error: Can't resolve './d:/Temp/cli/cli-test/src/$$_gendir/app/app.module.ngfactory' in 'E:\Temp\cli\cli-test\src'
 @ E:/Temp/cli/cli-test/src/main.ts 4:0-99
 @ multi ./src/main.ts

d:\Temp\cli\cli-test>

I have fixed this issue in my project.

In my case, I have found two reasons:

1. I used jade template. You can't use jade with AOT.

// My component.

@Component({ 
  selector: 'app-some-component', 
  template: require('jade-loader!./some-component.jade')(),  // <--- This will break AOT bundling.
  styleUrls: ['./some-component.styl'] 
}) 
export class SomeCompoonent implements OnInit {
  // ...
}

How to fix: bring html back or turn off AOT.

2. Export an anonymous function by using export default will break AOT bundling.

// my-utils.ts

export default function () {  // <--- This will break AOT bundling too.
  // ...
}

How t fix: give it a name or turn off AOT.

// my-utils.ts

export deafult function myUtils () {  // Yeah! Everything is fine!
  //...
}

Very useful @WiL-dev your comment works fine for me. 4.0.0

Building with --AOT today Angularcli V1.0.0

ERROR in Cannot assign to a reference or variable!

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

Build without AOT and then running, no real help.
Breaking on the throw I find the component name

After investigation I found I was using variable name 'year' changing to taxYear resolved issue. Must be a clash with a method somewhere.

@waratah How did you track down the error?

@altschuler Total guess work, year 'felt' like the source of the error as it was most recently added code. Nothing appeared wrong with the code and the last change I made was to add the year variable.

fixed my error with AppModule not a NgModule by updating typescript

npm install --save typescript@latest
`

try to add aot option, so build command will be like this :
ng build -prod --aot=false

In my case I was including some files that were meant for tests only, and I was including a typings.d.ts explicitly in tsconfig which also broke it.

I came across this error when i had a typo in my tsconfig file. There should maybe be a better error message, or sth that confirms that a valid tsconfig is present before starting the build.

It just ignored the broken tsconfig file and couldn't build aot since emitDecoratorMetadata was not enabled.

The most easy workaround (at least for me, that I had some beta version before), was to create a new whole project with the last Angular CLI version, and moves the src folder. It's no straight forward, so please read the migration guide and don't forget to make a backup before.

Migration guide

Here are the specifications about the building.

May I add that my version of the tool is:

$ ng -v
    _                      _                 ____ _     ___
   / \   _ __   __ _ _   _| | __ _ _ __     / ___| |   |_ _|
  / △ \ | '_ \ / _` | | | | |/ _` | '__|   | |   | |    | |
 / ___ \| | | | (_| | |_| | | (_| | |      | |___| |___ | |
/_/   \_\_| |_|\__, |\__,_|_|\__,_|_|       \____|_____|___|
               |___/
@angular/cli: 1.0.0-rc.2
node: 6.9.5
os: win32 x64
@angular/common: 2.4.9
@angular/compiler: 2.4.9
@angular/core: 2.4.9
@angular/forms: 2.4.9
@angular/http: 2.4.9
@angular/platform-browser: 2.4.9
@angular/platform-browser-dynamic: 2.4.9
@angular/router: 3.4.9
@angular/cli: 1.0.0-rc.2
@angular/compiler-cli: 2.4.9

I'm using ng build --prod without any problem and the last version in the repository is 1.1.1.

Responding as this seems to be a thread that is collecting a large amount of +1.
For me, turns out, the issue was compatibility with AOT in some code that my team wrote and a dependency that we took.

For us, this issue has since been resolved. Thank you.

I was getting this error and found that I had renamed a .ts file in Visual Studio. The old .js and .map files were still in the folder and apparently ng build was trying to include them in the build. Once I deleted these files, it worked fine. I added code in my build script to delete all .js and .map files from my src folder before each ng build so I don't run into this again.

This is seriously frustrating. My builds have just randomly stopped working with no clue in the error why. Even if I create a new project it breaks:

[swarman:/tmp/test] $ ng new testing
installing ng
  create .editorconfig
  create README.md
  create src/app/app.component.css
  create src/app/app.component.html
  create src/app/app.component.spec.ts
  create src/app/app.component.ts
  create src/app/app.module.ts
  create src/assets/.gitkeep
  create src/environments/environment.prod.ts
  create src/environments/environment.ts
  create src/favicon.ico
  create src/index.html
  create src/main.ts
  create src/polyfills.ts
  create src/styles.css
  create src/test.ts
  create src/tsconfig.app.json
  create src/tsconfig.spec.json
  create src/typings.d.ts
  create .angular-cli.json
  create e2e/app.e2e-spec.ts
  create e2e/app.po.ts
  create e2e/tsconfig.e2e.json
  create .gitignore
  create karma.conf.js
  create package.json
  create protractor.conf.js
  create tsconfig.json
  create tslint.json
Installing packages for tooling via npm.
Installed packages for tooling via npm.
Successfully initialized git.
Project 'testing' successfully created.
[swarman:/tmp/test] 47s $ cd testing/
[swarman:/tmp/test/testing] master 130 ± ng build --aot
Hash: c1b5f2a65555bd40d721                                                              
Time: 4136ms
chunk    {0} polyfills.bundle.js, polyfills.bundle.js.map (polyfills) 177 kB {4} [initial] [rendered]
chunk    {1} styles.bundle.js, styles.bundle.js.map (styles) 10.5 kB {4} [initial] [rendered]
chunk    {2} main.bundle.js, main.bundle.js.map (main) 1.09 kB {3} [initial] [rendered]
chunk    {3} vendor.bundle.js, vendor.bundle.js.map (vendor) 849 kB [initial] [rendered]
chunk    {4} inline.bundle.js, inline.bundle.js.map (inline) 0 bytes [entry] [rendered]

ERROR in ./src/main.ts
Module not found: Error: Can't resolve './$$_gendir/app/app.module.ngfactory' in '/tmp/test/testing/src'
 @ ./src/main.ts 3:0-74
 @ multi ./src/main.ts

version info:

[swarman:/tmp/test/testing] master 130 ± ng --version
    _                      _                 ____ _     ___
   / \   _ __   __ _ _   _| | __ _ _ __     / ___| |   |_ _|
  / △ \ | '_ \ / _` | | | | |/ _` | '__|   | |   | |    | |
 / ___ \| | | | (_| | |_| | | (_| | |      | |___| |___ | |
/_/   \_\_| |_|\__, |\__,_|_|\__,_|_|       \____|_____|___|
               |___/
@angular/cli: 1.2.3
node: 7.9.0
os: linux 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.2.3
@angular/compiler-cli: 4.3.1
@angular/language-service: 4.3.1

The same for me. Our builds stopped working since today morning. I decided to check it with just created application via 'ng new TestProject' and then 'ng build --prod --aot' and it produces the error like was mentioned in the post above: 'Module not found: Error: Can't resolve './$$_gendir/app/app.module.ngfactory''

_ng --version_ produces the following response:
@angular/cli: 1.2.3
node: 6.10.1
os: win32 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.2.3
@angular/compiler-cli: 4.3.1
@angular/language-service: 4.3.1

The issue is reproducible again since today morning.

Here is the result of _ng version_:
@angular/cli: 1.2.3
node: 6.10.3
os: win32 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/platform-browser: 4.3.1
@angular/platform-browser-dynamic: 4.3.1
@angular/router: 4.3.1
@angular/cli: 1.2.3
@angular/compiler-cli: 4.3.1
@angular/language-service: 4.3.1

Same here. My project just stopped compiling today morning:

@angular/cli: 1.2.3
node: 8.2.1
os: linux 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.2.3
@angular/compiler-cli: 4.3.1

FYI this issue is the top result in google for the error but I think the more relevant one is: https://github.com/angular/angular-cli/issues/7113

edit:

the workaround of npm install [email protected] worked for me.

@warmans beat me to it 👍. Hopfully @thaniri can re-open this

The real issue is the horrendous error messaging when AOT building fails. My AOT is failing, surely because of my fault, but I have no idea why. How can we print out the error?

I've started receiving this error all of the sudden as well, and my build hasn't changed. Seems like whatever is causing it happened in the last week or so.

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.

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 yarnusers there is another problem apparently

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

@jotatoledo using Angular 1.2.4 does not fix the problem for me unless enhanced-resolve is pinned to 3.3.0. To reproduce:

npm version 5.3.0

  • remove global npm cache directory (to simulate a brand new build)
  • npm i @angular/[email protected]
  • ng new testing
  • in testing directory: npm install && ng build --prod
  • got the "module not found error"
  • npm i [email protected]
  • ng build --prod works now
  • but package.json lists 'enhanced-resolve' version as '^3.3.0'
  • remove global npm cache, node_modules and package-lock.json (to simulate a brand new build)
  • npm build -prod fails again, because it pulls in enhanced-resolve 3.4.1.

My fix is to change my project's package.json to pin the enhanced-resolve to 3.3.0, remove node_modules and package-lock.json again, and ng build --prod works again.

I was able to resolve the issue while using @ngtools/[email protected] by locking webpack to version 3.3.0. Version 3.4.0 breaks my build.

I was using @ngtools/[email protected] with webpack without angular-cli. I was facing the same issue. I was able to resolve this by degrading @ngtools/webpack to 1.3.1 and adding [email protected] to package.json and deleting node_modules folder and package-lock.json file. After that running npm install resolved this issue.

Can someone post a package.json that fixes the problem and allows a clean install with yarn? Cause it doesn't work for me still and doesn't work even if I revert to earlier versions of CLI (e.g ^1.2.0, ^1.1.0). I guess because CLI had webpack dependencies as ^... and it automatically pulls broken version. Frontend development at it's prettiest:)

npm i @angular/[email protected] did the trick for me. It has [email protected] as its dependency.

@angular/cli: 1.2.4 fix the problem for me too. I discovered that running
ng serve or
ng build --prod or running
ng test

All produced (slightly different)ts compile errors because there are some stricter checks that are been done since the upgrade (for instance template checks are done).

But now we resolved all these errors, the project builds again and all tests pass!

npm i --save @angular/[email protected]

and changed package.json scripts to:

"scripts": {
    "ngstart": "ng serve",
    "start": "node server.js",
    "postinstall": "ng build --aot -prod",
    ...
  }

I'm having this issue too, I just created the app, made a "hello world" and I can't build it for production on Linux Mint 18.1 Serena. yarn add [email protected] --dev didn't help...

ERROR in ./src/main.ts
Module not found: Error: Can't resolve './$$_gendir/app/app.module.ngfactory' in '/home/filipe/Workspace/AppName/src'
 @ ./src/main.ts 3:0-74
 @ multi ./src/main.ts
@angular/cli: 1.2.4
node: 6.11.1
os: linux 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.2.4
@angular/compiler-cli: 4.3.1
@angular/language-service: 4.3.1

Edit:

this works ng build --aot=false -prod

@Itisfilipe that definitely works as @pbalaga and later @wassimsidia said. The problem with that hack is that you don't have the benefits of AOT(Faster rendering, Fewer asynchronous requests, Smaller Angular framework download size, Detect template errors earlier, Better security).
The main difference:

AOT, the compiler runs once at build time using one set of libraries; with JIT it runs every time for every user at runtime using a different set of libraries.

Some guides to fix it correctly:
First from @adessilly

Second - This one is a simple angular cli fix from @WiL-dev. I from my point of view that is not the case of the majority.

And the First Which is an article that explains basically:

A lambda assigned to a const is a function expression, not a function declaration. ngc interprets them as different things because it only analyses code statically.

const lambda => export function
default export => named export
moduleId should be set on components with templateUrl
dynamic component template => static template
private, protected accessors should be changed to public for any members accessed from template

from @awerlang

Updating to @angular/[email protected] fixed the problem for me.

Also for me, I uninstalled the temporary [email protected], then installed @angular/[email protected]
$ npm uninstall [email protected]
$ npm install @angular/[email protected]

@thaniri try @PhilipSultanescu solution worked for me. Just the part of updating angular/cli

$ npm install @angular/[email protected]

The new angular-cli version (@angular/[email protected]) fix the problem for me.

I tried all the above methods, did not solve this problem, has been troubled me for several days
image

@sirius77cc Can you show us the relevant package versions? Angular, ngtools, cli if you use it, etc.

Also sometimes I like to delete the node_modules folder and clear the cache npm cache clear -f just to be sure I got all the right versions when installing.. may be overkill.

I managed to fix this by upgrading angular-cli from 1.2.1 to 1.2.6.
Thanks guys

@MitchTalmadge thank you for your attention。The version information is as follows:
"scripts": {
"ng": "ng",
"start": "ng serve --host 0.0.0.0 --port 8080",
"build": "ng build --prod",
"clean": " ",
"test": "ng test",
"lint": "ng lint",
"e2e": "ng e2e"
},
"private": true,
"dependencies": {
"@angular/common": "^4.0.0",
"@angular/compiler": "^4.0.0",
"@angular/core": "^4.0.0",
"@angular/forms": "^4.0.0",
"@angular/http": "^4.0.0",
"@angular/platform-browser": "^4.0.0",
"@angular/platform-browser-dynamic": "^4.0.0",
"@angular/router": "^4.0.0",
"@ng-bootstrap/ng-bootstrap": "^1.0.0-alpha.24",
"bootbox": "^4.4.0",
"bootstrap": "^4.0.0-alpha.6",
"bootstrap-table": "^1.11.2",
"core-js": "^2.4.1",
"jquery": "^3.2.1",
"rxjs": "^5.1.0",
"tether": "^1.4.0",
"umebn-i18n": "^1.0.1",
"zenap-smart-table": "^1.2.0",
"zone.js": "^0.8.4",
"rest-ng-em-platform-eqlcm": "1.0.1",
"rest-ng-inventory-basic-eq":"1.0.1",
"rest-ng-inventory-basic-eh":"1.0.1",
"rest-ng-inventory-basic-me":"1.0.1"
},
"devDependencies": {
"@angular/cli": "^1.3.0-beta.0",
"@angular/compiler-cli": "^4.0.0",
"@types/jasmine": "2.5.38",
"@types/node": "~6.0.60",
"codelyzer": "~2.0.0",
"jasmine-core": "~2.5.2",
"jasmine-spec-reporter": "~3.2.0",
"karma": "~1.4.1",
"karma-chrome-launcher": "~2.0.0",
"karma-cli": "~1.0.1",
"karma-jasmine": "~1.1.0",
"karma-jasmine-html-reporter": "^0.2.2",
"karma-coverage-istanbul-reporter": "^0.2.0",
"protractor": "~5.1.0",
"ts-node": "~2.0.0",
"tslint": "~4.5.0",
"typescript": "^2.2.0"
}

@michjuh Tried the method, still did not solve,Thank you for your reply。

@sirius77cc Maybe try pinning 1.3.0-rc.3 for @angular/cli. I personally use the @angular/compiler-cli so I can't speak much about the cli's behavior. If that doesn't work, all I can suggest is to make sure your cache is cleared and that you have the right versions actually installed. Other than that, I don't see any problems in the package versions. I hope you get it worked out!

I got the same problem using 1.1.2 and the problem was that enhanced-resolve package is upgraded 3.4.x from 3.3.x

[email protected] addresses this issue. you can also pin enhanced-resolve to 3.3.0 in devDependencies in your package.json

@MitchTalmadge
I changed package.json to this, and finally resolved.The version server has 4.2.5,When i cleared the local directory Nodemoduls,The local installation of 4.2.5。Forced to change "^4.0.0" to "4.0.1"。
{
"name": "xxxxx",
"version": "1.0.1",
"license": "MIT",
"scripts": {
"ng": "ng",
"start": "ng serve --host 0.0.0.0 --port 8888",
"build": "ng build --dev --aot",
"clean": " ",
"test": "ng test",
"lint": "ng lint",
"e2e": "ng e2e"
},
"private": true,
"dependencies": {
"@angular/common": "4.0.1",
"@angular/compiler": "4.0.1",
"@angular/core": "4.0.1",
"@angular/forms": "4.0.1",
"@angular/http": "4.0.1",
"@angular/platform-browser": "4.0.1",
"@angular/platform-browser-dynamic": "4.0.1",
"@angular/router": "4.0.1",
"@ng-bootstrap/ng-bootstrap": "1.0.0-alpha.24",
"bootbox": "^4.4.0",
"bootstrap": "4.0.0-alpha.6",
"bootstrap-table": "1.11.2",
"core-js": "^2.4.1",
"jquery": "^3.2.1",
"ng2-translate": "^5.0.0",
"rxjs": "^5.1.0",
"tether": "^1.4.0",
"umebn-i18n": "^1.0.1",
"zenap-smart-table": "^1.2.0",
"zone.js": "^0.8.4"
},
"devDependencies": {
"@angular/cli": "1.2.0",
"@angular/compiler-cli": "4.0.1",
"@types/jasmine": "2.5.38",
"@types/node": "~6.0.60",
"codelyzer": "~2.0.0",
"jasmine-core": "~2.5.2",
"jasmine-spec-reporter": "~3.2.0",
"karma": "~1.4.1",
"karma-chrome-launcher": "~2.0.0",
"karma-cli": "~1.0.1",
"karma-jasmine": "~1.1.0",
"karma-jasmine-html-reporter": "^0.2.2",
"karma-coverage-istanbul-reporter": "^0.2.0",
"protractor": "~5.1.0",
"ts-node": "~2.0.0",
"tslint": "~4.5.0",
"typescript": "~2.2.0"
}
}

@sirius77cc Glad you got it worked out! :)

"prod": "ng build --env=prod --no-sourcemap" fixed for me

6 months and no official solution???

Yeah, none of these solutions have worked for me.

I FINALLY got it to work for me. Unbelievable it was because my entryModule path to the AppModule was incorrect. I fixed that and it works! Days of recreating my app from scratch, line by line, file by file, and it was a such as simple mistake but hard to notice.

If the compiler gave better error message, it would have saved me a LOTTTTT of time. Just saying "no appModule found at entryModule path, check that path is correct" would help.

@IAMtheIAM I can't find entryModule anywhere in my project. What file is this a part of?

I found out that another app of mine, which was using @angular/[email protected], @angular/*@4.2.4, and [email protected], successfully built using --prod, but when I ran npm update to get @angular/*@4.3.4 and [email protected], it produced the error. I tried several permutations of pinning various suggested versions of @angular/cli and enhanced-resolve along with several versions of @angular/* with no success. I really hope this is fixed soon.

Edit: However, pinning @angular/[email protected], @angular/*@4.2.4, and [email protected] to my other app did not fix the issue. So there is something else really obscure going on, possibly with another dependency that hasn't been mentioned? :/

It worked for me installing @angular/[email protected] with angular 4

"@angular/common": "^4.0.0",
"@angular/compiler": "^4.0.0",
"@angular/core": "^4.0.0",
"@angular/forms": "^4.0.0",
"@angular/http": "^4.0.0",
"@angular/platform-browser": "^4.0.0",
"@angular/platform-browser-dynamic": "^4.0.0",
"@angular/router": "^4.0.0"

I have taken sample AngularCli app from Git. I installed all node modules via npm install. Now trying to build app via ng build -prod giving error,
Environment:

  1. Angular2.
  2. Material Bootstrap.
  3. Angular-cli based project.

[
ERROR in ./src/main.ts
Module not found: Error: Can't resolve './$$_gendir/app/app.module.ngfactory' in 'D:\ng testprasad\src'
@ ./src/main.ts 4:0-74
@ multi ./src/main.ts
]

Any help is really appreciated..... !!!!

The comand I tried may not be perfect:
ng build --prod --aot=false

I resolved this issue in my project by pinning enhanced-resolve to 3.3.0. In case anyone needs to do it:

  1. npm shrinkwrap
  2. edit the shrinkwrap file and set all version of enhanced-resolve to 3.3.0
  3. npm install

More info here: https://stackoverflow.com/questions/15806152/how-do-i-override-nested-npm-dependency-versions

You can also do a similar thing with yarn. Just edit the yarn.lock file the same way, setting the resolved property for enhanced-resolve to "https://registry.yarnpkg.com/enhanced-resolve/-/enhanced-resolve-3.3.0.tgz"

Good luck y'all.

sure will try it.

why this happening in build tools. isnt there any permanent solution irrespective of versions?

Try to use ng build --prod --aot=false, but build that appear in ./dist doesn't work. Files of bundles are not found. Does anyone catch this problem ?

Just change

"@angular/cli": "1.0.0"

from devDependencies to

"@angular/cli": "1.3.0"

run npm install and it should be fine.

In the current night I found perfect solution: remove everything, remove npm, remove node_modules. Burn them all! Dracarys! Then go to install npm, install angular-cli, have a good day

remove everything, remove npm, remove node_modules. Burn them all! Dracarys!

"nukeInstall": "rm -rf node_modules && npm cache clean --force && npm install"

@BOPOHOB On that note, I added this to my package.json scripts about a month ago. Works very well for that.

@jakeNiemiec @BOPOHOB I would also add to the removal of the npm-shrinkwrap.json and package-lock.json

"nukeInstall": "rm -rf node_modules npm-shrinkwrap.json package-lock.json && npm cache clean --force && npm install"

I followed the instruction from the README to upgrade angular-cli and now it works greathttps://github.com/angular/angular-cli#updating-angular-cli

below is the instruction:

To update Angular CLI to a new version, you must update both the global package and your project's local package.

Global package:

npm uninstall -g @angular/cli npm cache clean npm install -g @angular/cli@latest

Local project package:

rm -rf node_modules dist # use rmdir /S/Q node_modules dist in Windows Command Prompt; use rm -r -fo node_modules,dist in Windows PowerShell npm install --save-dev @angular/cli@latest npm install

@IRCraziestTaxi you can put entryModule on either your webpack config or your typescript config. Make sure the tsConfigPath points to the proper location of your tsconfig file. Also, the tsconfig settings are VERY picky, below I copied my entire working file so try that as is before modifying anything.

// webpack config

const ngToolsWebpack = require('@ngtools/webpack');

// webpack loader

          { test: /\.ts$/, loader: ['@ngtools/webpack'] },

// webpack plugin

      new ngToolsWebpack.AotPlugin({
         tsConfigPath: './tsconfig.ngtools-webpack.json',
         entryModule: helpers.root('src/app-components/app/app.module') + '#AppModule', // here
         debug: true
      }),
// tsconfig.ngtools-webpack.json

{
   "compilerOptions": {
      "allowSyntheticDefaultImports": true,
      "baseUrl": ".",
      "emitDecoratorMetadata": true,
      "experimentalDecorators": true,
      "importHelpers": true,
      "lib": [
         "dom",
         "es2015"
      ],
      "module": "es2015",
      "moduleResolution": "node",
      "noEmit": true,
      "noEmitHelpers": true,
      "paths": {
         "@angular/*": [
            "./node_modules/@angular/*"
         ]
      },
      "sourceMap": true,
      "sourceRoot": ".",
      "strictNullChecks": false,
      "target": "es5",
      "typeRoots": [
         "./node_modules/@types"
      ],
      "types": [
         "hammerjs",
         "node"
      ]
   },
   "exclude": [
      "./node_modules",
      "./wwwroot",
      "../backend-nodejs",
      "./src/**/*.e2e.ts",
      "./src/**/*.spec.ts"
   ],
   "angularCompilerOptions": {
      "genDir": "./compiled",
       "entryModule": "src/app-components/app/app.module#AppModule", // or here
      "skipMetadataEmit": true
   },
   "atom": {
      "rewriteTsconfig": false
   },
   "awesomeTypescriptLoaderOptions": {
      "forkChecker": true,
      "useWebpackText": true
   },
   "buildOnSave": false,
   "compileOnSave": false
}

fwiw ... In case this might help others, I was able to resolve this error by updating both my global and project angular-cli from 1.0.3 to 1.3.1 (the latest as of this writing), per the instructions on the Angular CLI ReadMe. I didn't make any other changes to my project.

For me, the issue was happening only when doing an ng build --prod or ng serve --prod. In contrast, development builds (i.e., without the --prod) ran without error.

Installing @angular/[email protected] fix this

my previous @angular/[email protected] had conflict with npm packages.

-- upgrade global angular-cli to @latest

npm uninstall -g angular-cli
npm cache clean
npm install -g @angular/cli

your-angular-project-dir> npm install --save-dev @angular/cli@latest

after upgrade to @lastest, all works

i have same problem after uninstall previous version of angular cli and then update to "@angular/cli": "^1.2.4", solve my issue
my debug in terminal is

mrnull@mrnull-mrnull:~/Desktop/ecowalls$ ng build --env=prod
Hash: 985921a97b2ef5b04336
Time: 24034ms
chunk {0} 0.chunk.js, 0.chunk.js.map 1.08 MB {1} {2} {3} {5} [rendered]
chunk {1} 1.chunk.js, 1.chunk.js.map 83 kB {0} {2} {3} {5} [rendered]
chunk {2} 2.chunk.js, 2.chunk.js.map 15.4 kB {0} {1} {3} {5} [rendered]
chunk {3} 3.chunk.js, 3.chunk.js.map 2.75 kB {0} {1} {2} {5} [rendered]
chunk {4} polyfills.bundle.js, polyfills.bundle.js.map (polyfills) 178 kB {8} [initial] [rendered]
chunk {5} main.bundle.js, main.bundle.js.map (main) 21.7 kB {7} [initial] [rendered]
chunk {6} styles.bundle.js, styles.bundle.js.map (styles) 10.5 kB {8} [initial] [rendered]
chunk {7} vendor.bundle.js, vendor.bundle.js.map (vendor) 3.25 MB [initial] [rendered]
chunk {8} inline.bundle.js, inline.bundle.js.map (inline) 0 bytes [entry] [rendered]

ERROR in ./src/environments/environment.ts
Module build failed: TypeError: Cannot read property 'flags' of undefined
at getSymbolLinks (/home/mrnull/Desktop/ecowalls/node_modules/typescript/lib/typescript.js:26080:23)
at getTypeOfVariableOrParameterOrProperty (/home/mrnull/Desktop/ecowalls/node_modules/typescript/lib/typescript.js:29345:25)
at checkVariableLikeDeclaration (/home/mrnull/Desktop/ecowalls/node_modules/typescript/lib/typescript.js:43177:41)
at checkVariableDeclaration (/home/mrnull/Desktop/ecowalls/node_modules/typescript/lib/typescript.js:43233:20)
at checkSourceElement (/home/mrnull/Desktop/ecowalls/node_modules/typescript/lib/typescript.js:45111:28)
at Object.forEach (/home/mrnull/Desktop/ecowalls/node_modules/typescript/lib/typescript.js:1449:30)
at checkVariableStatement (/home/mrnull/Desktop/ecowalls/node_modules/typescript/lib/typescript.js:43242:16)
at checkSourceElement (/home/mrnull/Desktop/ecowalls/node_modules/typescript/lib/typescript.js:45080:28)
at Object.forEach (/home/mrnull/Desktop/ecowalls/node_modules/typescript/lib/typescript.js:1449:30)
at checkSourceFileWorker (/home/mrnull/Desktop/ecowalls/node_modules/typescript/lib/typescript.js:45198:20)
at checkSourceFile (/home/mrnull/Desktop/ecowalls/node_modules/typescript/lib/typescript.js:45178:13)
at getDiagnosticsWorker (/home/mrnull/Desktop/ecowalls/node_modules/typescript/lib/typescript.js:45242:17)
at getDiagnostics (/home/mrnull/Desktop/ecowalls/node_modules/typescript/lib/typescript.js:45228:24)
at Object.getEmitResolver (/home/mrnull/Desktop/ecowalls/node_modules/typescript/lib/typescript.js:25898:13)
at /home/mrnull/Desktop/ecowalls/node_modules/typescript/lib/typescript.js:67689:69
at runWithCancellationToken (/home/mrnull/Desktop/ecowalls/node_modules/typescript/lib/typescript.js:67447:24)
@ ./src/main.ts 4:0-57
@ multi ./src/main.ts
mrnull@mrnull-mrnull:~/Desktop/ecowalls$
mrnull@mrnull-mrnull:~/Desktop/ecowalls$ ng build --prod --aot=true
Hash: 28c29744b9915dd78c34
Time: 20301ms
chunk {0} polyfills.f77454f386e1728adda2.bundle.js (polyfills) 178 kB {4} [initial] [rendered]
chunk {1} main.b46ba2bf68a6b3600bc3.bundle.js (main) 2.44 kB {3} [initial] [rendered]
chunk {2} styles.d41d8cd98f00b204e980.bundle.css (styles) 69 bytes {4} [initial] [rendered]
chunk {3} vendor.d1e70980d2f78b0ceaaa.bundle.js (vendor) 849 kB [initial] [rendered]
chunk {4} inline.eb7d51cec64ef9b22661.bundle.js (inline) 0 bytes [entry] [rendered]

ERROR in ./src/main.ts
Module not found: Error: Can't resolve './$$_gendir/app/app.module.ngfactory' in '/home/mrnull/Desktop/ecowalls/src'
@ ./src/main.ts 3:0-74
@ multi ./src/main.ts

ERROR in ./src/environments/environment.ts
Module build failed: TypeError: Cannot read property 'flags' of undefined
at getSymbolLinks (/home/mrnull/Desktop/ecowalls/node_modules/typescript/lib/typescript.js:26080:23)
at getTypeOfVariableOrParameterOrProperty (/home/mrnull/Desktop/ecowalls/node_modules/typescript/lib/typescript.js:29345:25)
at checkVariableLikeDeclaration (/home/mrnull/Desktop/ecowalls/node_modules/typescript/lib/typescript.js:43177:41)
at checkVariableDeclaration (/home/mrnull/Desktop/ecowalls/node_modules/typescript/lib/typescript.js:43233:20)
at checkSourceElement (/home/mrnull/Desktop/ecowalls/node_modules/typescript/lib/typescript.js:45111:28)
at Object.forEach (/home/mrnull/Desktop/ecowalls/node_modules/typescript/lib/typescript.js:1449:30)
at checkVariableStatement (/home/mrnull/Desktop/ecowalls/node_modules/typescript/lib/typescript.js:43242:16)
at checkSourceElement (/home/mrnull/Desktop/ecowalls/node_modules/typescript/lib/typescript.js:45080:28)
at Object.forEach (/home/mrnull/Desktop/ecowalls/node_modules/typescript/lib/typescript.js:1449:30)
at checkSourceFileWorker (/home/mrnull/Desktop/ecowalls/node_modules/typescript/lib/typescript.js:45198:20)
at checkSourceFile (/home/mrnull/Desktop/ecowalls/node_modules/typescript/lib/typescript.js:45178:13)
at getDiagnosticsWorker (/home/mrnull/Desktop/ecowalls/node_modules/typescript/lib/typescript.js:45242:17)
at getDiagnostics (/home/mrnull/Desktop/ecowalls/node_modules/typescript/lib/typescript.js:45228:24)
at Object.getEmitResolver (/home/mrnull/Desktop/ecowalls/node_modules/typescript/lib/typescript.js:25898:13)
at /home/mrnull/Desktop/ecowalls/node_modules/typescript/lib/typescript.js:67689:69
at runWithCancellationToken (/home/mrnull/Desktop/ecowalls/node_modules/typescript/lib/typescript.js:67447:24)
@ ./src/main.ts 2:0-57
@ multi ./src/main.ts

ERROR in ./src/$$_gendir async
Module not found: Error: Can't resolve '/home/mrnull/Desktop/ecowalls/src/$$_gendir/app/admin/admin.module.ngfactory.ts' in '/home/mrnull/Desktop/ecowalls/src/$$_gendir'
@ ./src/$$_gendir async
@ ./~/@angular/core/@angular/core.es5.js
@ ./src/main.ts
@ multi ./src/main.ts

ERROR in ./src/$$_gendir async
Module not found: Error: Can't resolve '/home/mrnull/Desktop/ecowalls/src/$$_gendir/app/admin/pages/pages.module.ngfactory.ts' in '/home/mrnull/Desktop/ecowalls/src/$$_gendir'
@ ./src/$$_gendir async
@ ./~/@angular/core/@angular/core.es5.js
@ ./src/main.ts
@ multi ./src/main.ts

ERROR in ./src/$$_gendir async
Module not found: Error: Can't resolve '/home/mrnull/Desktop/ecowalls/src/$$_gendir/app/admin/pages/dashboard/dashboard.module.ngfactory.ts' in '/home/mrnull/Desktop/ecowalls/src/$$_gendir'
@ ./src/$$_gendir async
@ ./~/@angular/core/@angular/core.es5.js
@ ./src/main.ts
@ multi ./src/main.ts

ERROR in ./src/$$_gendir async
Module not found: Error: Can't resolve '/home/mrnull/Desktop/ecowalls/src/$$_gendir/app/admin/login/login.module.ngfactory.ts' in '/home/mrnull/Desktop/ecowalls/src/$$_gendir'
@ ./src/$$_gendir async
@ ./~/@angular/core/@angular/core.es5.js
@ ./src/main.ts
@ multi ./src/main.ts
mrnull@mrnull-mrnull:~/Desktop/ecowalls$
mrnull@mrnull-mrnull:~/Desktop/ecowalls$ ng build --aot
Hash: e5cbdb3c184e874bd05b
Time: 16305ms
chunk {0} polyfills.bundle.js, polyfills.bundle.js.map (polyfills) 178 kB {4} [initial] [rendered]
chunk {1} styles.bundle.js, styles.bundle.js.map (styles) 10.5 kB {4} [initial] [rendered]
chunk {2} main.bundle.js, main.bundle.js.map (main) 1.09 kB {3} [initial] [rendered]
chunk {3} vendor.bundle.js, vendor.bundle.js.map (vendor) 849 kB [initial] [rendered]
chunk {4} inline.bundle.js, inline.bundle.js.map (inline) 0 bytes [entry] [rendered]

ERROR in ./src/main.ts
Module not found: Error: Can't resolve './$$_gendir/app/app.module.ngfactory' in '/home/mrnull/Desktop/ecowalls/src'
@ ./src/main.ts 3:0-74
@ multi ./src/main.ts

ERROR in ./src/$$_gendir async
Module not found: Error: Can't resolve '/home/mrnull/Desktop/ecowalls/src/$$_gendir/app/admin/admin.module.ngfactory.ts' in '/home/mrnull/Desktop/ecowalls/src/$$_gendir'
@ ./src/$$_gendir async
@ ./~/@angular/core/@angular/core.es5.js
@ ./src/main.ts
@ multi ./src/main.ts

ERROR in ./src/$$_gendir async
Module not found: Error: Can't resolve '/home/mrnull/Desktop/ecowalls/src/$$_gendir/app/admin/pages/pages.module.ngfactory.ts' in '/home/mrnull/Desktop/ecowalls/src/$$_gendir'
@ ./src/$$_gendir async
@ ./~/@angular/core/@angular/core.es5.js
@ ./src/main.ts
@ multi ./src/main.ts

ERROR in ./src/$$_gendir async
Module not found: Error: Can't resolve '/home/mrnull/Desktop/ecowalls/src/$$_gendir/app/admin/pages/dashboard/dashboard.module.ngfactory.ts' in '/home/mrnull/Desktop/ecowalls/src/$$_gendir'
@ ./src/$$_gendir async
@ ./~/@angular/core/@angular/core.es5.js
@ ./src/main.ts
@ multi ./src/main.ts

ERROR in ./src/$$_gendir async
Module not found: Error: Can't resolve '/home/mrnull/Desktop/ecowalls/src/$$_gendir/app/admin/login/login.module.ngfactory.ts' in '/home/mrnull/Desktop/ecowalls/src/$$_gendir'
@ ./src/$$_gendir async
@ ./~/@angular/core/@angular/core.es5.js
@ ./src/main.ts
@ multi ./src/main.ts
mrnull@mrnull-mrnull:~/Desktop/ecowalls$
mrnull@mrnull-mrnull:~/Desktop/ecowalls$ ng build --prod
Hash: 826eade7e3d0c2da0c9b
Time: 19905ms
chunk {0} polyfills.f77454f386e1728adda2.bundle.js (polyfills) 178 kB {4} [initial] [rendered]
chunk {1} main.b46ba2bf68a6b3600bc3.bundle.js (main) 2.44 kB {3} [initial] [rendered]
chunk {2} styles.d41d8cd98f00b204e980.bundle.css (styles) 69 bytes {4} [initial] [rendered]
chunk {3} vendor.d1e70980d2f78b0ceaaa.bundle.js (vendor) 849 kB [initial] [rendered]
chunk {4} inline.eb7d51cec64ef9b22661.bundle.js (inline) 0 bytes [entry] [rendered]

ERROR in ./src/main.ts
Module not found: Error: Can't resolve './$$_gendir/app/app.module.ngfactory' in '/home/mrnull/Desktop/ecowalls/src'
@ ./src/main.ts 3:0-74
@ multi ./src/main.ts

ERROR in ./src/environments/environment.ts
Module build failed: TypeError: Cannot read property 'flags' of undefined
at getSymbolLinks (/home/mrnull/Desktop/ecowalls/node_modules/typescript/lib/typescript.js:26080:23)
at getTypeOfVariableOrParameterOrProperty (/home/mrnull/Desktop/ecowalls/node_modules/typescript/lib/typescript.js:29345:25)
at checkVariableLikeDeclaration (/home/mrnull/Desktop/ecowalls/node_modules/typescript/lib/typescript.js:43177:41)
at checkVariableDeclaration (/home/mrnull/Desktop/ecowalls/node_modules/typescript/lib/typescript.js:43233:20)
at checkSourceElement (/home/mrnull/Desktop/ecowalls/node_modules/typescript/lib/typescript.js:45111:28)
at Object.forEach (/home/mrnull/Desktop/ecowalls/node_modules/typescript/lib/typescript.js:1449:30)
at checkVariableStatement (/home/mrnull/Desktop/ecowalls/node_modules/typescript/lib/typescript.js:43242:16)
at checkSourceElement (/home/mrnull/Desktop/ecowalls/node_modules/typescript/lib/typescript.js:45080:28)
at Object.forEach (/home/mrnull/Desktop/ecowalls/node_modules/typescript/lib/typescript.js:1449:30)
at checkSourceFileWorker (/home/mrnull/Desktop/ecowalls/node_modules/typescript/lib/typescript.js:45198:20)
at checkSourceFile (/home/mrnull/Desktop/ecowalls/node_modules/typescript/lib/typescript.js:45178:13)
at getDiagnosticsWorker (/home/mrnull/Desktop/ecowalls/node_modules/typescript/lib/typescript.js:45242:17)
at getDiagnostics (/home/mrnull/Desktop/ecowalls/node_modules/typescript/lib/typescript.js:45228:24)
at Object.getEmitResolver (/home/mrnull/Desktop/ecowalls/node_modules/typescript/lib/typescript.js:25898:13)
at /home/mrnull/Desktop/ecowalls/node_modules/typescript/lib/typescript.js:67689:69
at runWithCancellationToken (/home/mrnull/Desktop/ecowalls/node_modules/typescript/lib/typescript.js:67447:24)
@ ./src/main.ts 2:0-57
@ multi ./src/main.ts

ERROR in ./src/$$_gendir async
Module not found: Error: Can't resolve '/home/mrnull/Desktop/ecowalls/src/$$_gendir/app/admin/admin.module.ngfactory.ts' in '/home/mrnull/Desktop/ecowalls/src/$$_gendir'
@ ./src/$$_gendir async
@ ./~/@angular/core/@angular/core.es5.js
@ ./src/main.ts
@ multi ./src/main.ts

ERROR in ./src/$$_gendir async
Module not found: Error: Can't resolve '/home/mrnull/Desktop/ecowalls/src/$$_gendir/app/admin/pages/pages.module.ngfactory.ts' in '/home/mrnull/Desktop/ecowalls/src/$$_gendir'
@ ./src/$$_gendir async
@ ./~/@angular/core/@angular/core.es5.js
@ ./src/main.ts
@ multi ./src/main.ts

ERROR in ./src/$$_gendir async
Module not found: Error: Can't resolve '/home/mrnull/Desktop/ecowalls/src/$$_gendir/app/admin/pages/dashboard/dashboard.module.ngfactory.ts' in '/home/mrnull/Desktop/ecowalls/src/$$_gendir'
@ ./src/$$_gendir async
@ ./~/@angular/core/@angular/core.es5.js
@ ./src/main.ts
@ multi ./src/main.ts

ERROR in ./src/$$_gendir async
Module not found: Error: Can't resolve '/home/mrnull/Desktop/ecowalls/src/$$_gendir/app/admin/login/login.module.ngfactory.ts' in '/home/mrnull/Desktop/ecowalls/src/$$_gendir'
@ ./src/$$_gendir async
@ ./~/@angular/core/@angular/core.es5.js
@ ./src/main.ts
@ multi ./src/main.ts
mrnull@mrnull-mrnull:~/Desktop/ecowalls$
mrnull@mrnull-mrnull:~/Desktop/ecowalls$ npm uninstall --save @angular/cli
npm WARN @angular/[email protected] requires a peer of @angular/[email protected] but none was installed.
npm WARN [email protected] requires a peer of @types/chartist@^0.9.34 but none was installed.
npm WARN optional SKIPPING OPTIONAL DEPENDENCY: [email protected] (node_modules/fsevents):
npm WARN notsup SKIPPING OPTIONAL DEPENDENCY: Unsupported platform for [email protected]: wanted {"os":"darwin","arch":"any"} (current: {"os":"linux","arch":"x64"})

added 114 packages and removed 513 packages in 22.677s

╭─────────────────────────────────────╮
│ │
│ Update available 5.3.0 → 5.4.2 │
│ Run npm i -g npm to update │
│ │
╰─────────────────────────────────────╯

mrnull@mrnull-mrnull:~/Desktop/ecowalls$ npm uninstall --save @angular/[email protected]
npm WARN @angular/[email protected] requires a peer of @angular/[email protected] but none was installed.
npm WARN [email protected] requires a peer of @types/chartist@^0.9.34 but none was installed.
npm WARN optional SKIPPING OPTIONAL DEPENDENCY: [email protected] (node_modules/fsevents):
npm WARN notsup SKIPPING OPTIONAL DEPENDENCY: Unsupported platform for [email protected]: wanted {"os":"darwin","arch":"any"} (current: {"os":"linux","arch":"x64"})

added 114 packages and updated 1 package in 8.754s
mrnull@mrnull-mrnull:~/Desktop/ecowalls$

mrnull@mrnull-mrnull:~/Desktop/ecowalls$ ng build --prod
Unable to find "@angular/cli" in devDependencies.

Please take the following steps to avoid issues:
"npm install --save-dev @angular/cli@latest"

The "@angular/compiler-cli" package was not properly installed.
Error: The "@angular/compiler-cli" package was not properly installed.
at Object. (/usr/local/lib/node_modules/@angular/cli/node_modules/@ngtools/webpack/src/index.js:14:11)
at Module._compile (module.js:573:30)
at Object.Module._extensions..js (module.js:584:10)
at Module.load (module.js:507:32)
at tryModuleLoad (module.js:470:12)
at Function.Module._load (module.js:462:3)
at Module.require (module.js:517:17)
at require (internal/module.js:11:18)
at Object. (/usr/local/lib/node_modules/@angular/cli/tasks/eject.js:10:19)
at Module._compile (module.js:573:30)
at Object.Module._extensions..js (module.js:584:10)
at Module.load (module.js:507:32)
at tryModuleLoad (module.js:470:12)
at Function.Module._load (module.js:462:3)
at Module.require (module.js:517:17)
at require (internal/module.js:11:18)
mrnull@mrnull-mrnull:~/Desktop/ecowalls$ npm install --save @angular/[email protected]

[email protected] install /home/mrnull/Desktop/ecowalls/node_modules/node-sass
node scripts/install.js

Cached binary found at /home/mrnull/.npm/node-sass/4.5.3/linux-x64-57_binding.node

[email protected] postinstall /home/mrnull/Desktop/ecowalls/node_modules/node-sass
node scripts/build.js

Binary found at /home/mrnull/Desktop/ecowalls/node_modules/node-sass/vendor/linux-x64-57/binding.node
Testing binary
Binary is fine
npm WARN @angular/[email protected] requires a peer of @angular/[email protected] but none was installed.
npm WARN [email protected] requires a peer of @types/chartist@^0.9.34 but none was installed.
npm WARN optional SKIPPING OPTIONAL DEPENDENCY: [email protected] (node_modules/fsevents):
npm WARN notsup SKIPPING OPTIONAL DEPENDENCY: Unsupported platform for [email protected]: wanted {"os":"darwin","arch":"any"} (current: {"os":"linux","arch":"x64"})

  • @angular/[email protected]
    added 639 packages in 73.787s
    mrnull@mrnull-mrnull:~/Desktop/ecowalls$
    mrnull@mrnull-mrnull:~/Desktop/ecowalls$ ng build --prod
    10% building modules 5/7 modules 2 active ...ull/Desktop/ecowalls/src/polyfills.tsThe final argument to magicString.overwrite(...) should be an options object. See https://github.com/rich-harris/magic-string
    Hash: 035d3639ffc1f014a9e3
    Time: 39791ms
    chunk {0} 0.c35d0e1b7569c2893e26.chunk.js 1.49 MB {1} {2} {3} {5} [rendered]
    chunk {1} 1.057d4ed5fcf1aa98d22f.chunk.js 315 kB {0} {2} {3} {5} [rendered]
    chunk {2} 2.b440bf9d2b946fbcf9c1.chunk.js 46.2 kB {0} {1} {3} {5} [rendered]
    chunk {3} 3.933c65d31f4e2505e454.chunk.js 4.05 kB {0} {1} {2} {5} [rendered]
    chunk {4} polyfills.7bb85227ebb5989e30a5.bundle.js (polyfills) 178 kB {8} [initial] [rendered]
    chunk {5} main.7e296abc0250ef362bbf.bundle.js (main) 30 kB {7} [initial] [rendered]
    chunk {6} styles.d41d8cd98f00b204e980.bundle.css (styles) 69 bytes {8} [initial] [rendered]
    chunk {7} vendor.060a1b920b5f28e44455.bundle.js (vendor) 2.28 MB [initial] [rendered]
    chunk {8} inline.48edbf28269d5d8bfdd1.bundle.js (inline) 0 bytes [entry] [rendered]
    mrnull@mrnull-mrnull:~/Desktop/ecowalls$ ng build --prod --aot
    10% building modules 5/7 modules 2 active ...ull/Desktop/ecowalls/src/polyfills.tsThe final argument to magicString.overwrite(...) should be an options object. See https://github.com/rich-harris/magic-string
    Hash: de71af4beaede60e81a3
    Time: 45164ms
    chunk {0} 0.c35d0e1b7569c2893e26.chunk.js 1.49 MB {1} {2} {3} {5} [rendered]
    chunk {1} 1.057d4ed5fcf1aa98d22f.chunk.js 315 kB {0} {2} {3} {5} [rendered]
    chunk {2} 2.b440bf9d2b946fbcf9c1.chunk.js 46.2 kB {0} {1} {3} {5} [rendered]
    chunk {3} 3.933c65d31f4e2505e454.chunk.js 4.05 kB {0} {1} {2} {5} [rendered]
    chunk {4} polyfills.7bb85227ebb5989e30a5.bundle.js (polyfills) 178 kB {8} [initial] [rendered]
    chunk {5} main.7e296abc0250ef362bbf.bundle.js (main) 30 kB {7} [initial] [rendered]
    chunk {6} styles.d41d8cd98f00b204e980.bundle.css (styles) 69 bytes {8} [initial] [rendered]
    chunk {7} vendor.060a1b920b5f28e44455.bundle.js (vendor) 2.28 MB [initial] [rendered]
    chunk {8} inline.48edbf28269d5d8bfdd1.bundle.js (inline) 0 bytes [entry] [rendered]
    mrnull@mrnull-mrnull:~/Desktop/ecowalls$

Running angular 4.0.0

upgrading @angular/cli to v1.2.5 with npm install --save @angular/[email protected]

check if there is an uppercase letter in your module directory path


Go into node_modules/webpack/ directory then install [email protected] work for me.

problem

There is no 'enhanced-resolve' package in my package.json, and not in the root of the node_modules. So I run yarn add [email protected] --dev, then ng build --prod still not work. then I checked package list by run yarn list, I find [email protected] in package.json from @angular-cli/webpack but [email protected] installed in the webpack. So I go into the webpack directory and force install [email protected], then it's work for me.

After trying different permutations of different versions of everything, I FINALLY got this figured out and I couldn't believe the reason. A while back, in order to get my dev build/serve working, I had to add **/*.d.ts to the include array in my tsconfig, otherwise I got all kinds of "cannot find name" errors. I did not realize that the reason that was happening was because tsconfig.app.json was generated by the CLI with an empty types array, so even though the base tsconfig.json specified the correct "typeRoots" directory, the empty types array was causing the errors. Even though adding **/*.d.ts to the include array fixed dev build/serve errors, it was the reason for the prod build error in this issue. Removing that and the empty types array in tsconfig.app.json allowed me to build both dev and prod successfully. Hopefully this will help somebody else.

use @angular/[email protected] solved my problem

I am facing same issue. I have angular cli 1.5.0

Angular CLI: 1.5.0
Node: 8.9.0
OS: darwin x64
Angular: 5.0.0
... animations, common, compiler, core, forms, http
... language-service, platform-browser, platform-browser-dynamic
... platform-server, router

@angular/cli: 1.5.0
@angular/compiler-cli: 4.4.6
@angular/tsc-wrapped: 4.4.6
@angular-devkit/build-optimizer: 0.0.32
@angular-devkit/core: 0.0.20
@angular-devkit/schematics: 0.0.35
@ngtools/json-schema: 1.1.0
@ngtools/webpack: 1.8.0
@schematics/angular: 0.1.0
typescript: 2.6.1
webpack: 3.8.1

Updating your packages, especially Angular CLI and Webpack fixed the problem for me. Try that and see the difference. Am using "@angular/cli": "^1.5.0", and "webpack": "^3.8.1"

I had the same problem, just followed official document to update to the last version of angular-cli solved the problem. There are two steps.

To update Angular CLI to a new version, you must update both the global package and your project's local package.

Global package:

npm uninstall -g @angular/cli
npm cache clean
# if npm version is > 5 then use `npm cache verify` to avoid errors (or to avoid using --force)
npm install -g @angular/cli@latest

Local project package:

rm -rf node_modules dist # use rmdir /S/Q node_modules dist in Windows Command Prompt; use rm -r -fo node_modules,dist in Windows PowerShell
npm install --save-dev @angular/cli@latest
npm install

Ref: https://github.com/angular/angular-cli#updating-angular-cli

Hi all,

After run of "ng build --prod" I have this issue:
"ERROR in ./src/main.ts
Module not found: Error: Can't resolve './$$_gendir/app/app.module.ngfactory'"

I have Angular CLI 1.5.0.
My main.ts:

import { platformBrowserDynamic } from '@angular/platform-browser-dynamic';
import { enableProdMode } from '@angular/core';

import { AppModule } from './app/app.module';

enableProdMode();
platformBrowserDynamic().bootstrapModule(AppModule);

what is wrong here, how to fix this issue?

@filip88etf . I had a similar issue and the cause (in my case) was that I had upgraded typescript to a non-supported version. By supported version I mean supported by the angular framework version I was currently running which happened to be 4.4.6 . The current supported typescript version for 4.4.6 is 2.4.2.

I created a new project using angular-cli 1.5.0 and copied my existing code to that project. Its not a solution but i don't want to put more time in inspecting whats wrong with compiler.

There were two ways I could fix this-
1] Updating typescript to latest
npm install --save typescript@latest
2] make the aot flag false
ng build --prod --aot=false

I had the same error as it was just a silly mistake. I installed third party libraries without --save..So at the time of build it was not able to find the package in package.json( may be this is the reason i guess).
Hope this will benefit someone.

ng build --prod --aot false

This solved my problem.

It is not a solution though.

Later,

  • I updated the cli again
  • Followed the error messages and fixed them
    Now there's no complain

Everybody, please note that while using --aot false is a workaround that might allow you to build, you do lose the benefits of AOT compilation, so you should still be searching for a real solution.

I just ran into the same issue. Since we switched to aot build for development, this issue was troubling. And in my case it was caused by a previous fix involving angularCompilerOptions in the tsconfig.app.json:

I basically had

before - not working

{
  "compilerOptions": {
    "sourceMap": true,
    "declaration": false,
    "moduleResolution": "node",
    "emitDecoratorMetadata": true,
    "experimentalDecorators": true,
    "noImplicitAny": true,
    "lib": [
      "es2016",
      "dom"
    ],
    "outDir": "../out-tsc/app",
    "target": "es5",
    "module": "es2015",
    "baseUrl": "",
    "types": []
  },
  "angularCompilerOptions": {
    "annotateForClosureCompiler": false,
    "skipMetadataEmit" : true,
    "skipTemplateCodegen": true
  },
  "exclude": [
    "test.ts",
    "**/*.spec.ts"
  ]
}

removing the angularCompilerOptions solved the issue:

working

{
  "compilerOptions": {
    "sourceMap": true,
    "declaration": false,
    "moduleResolution": "node",
    "emitDecoratorMetadata": true,
    "experimentalDecorators": true,
    "noImplicitAny": true,
    "lib": [
      "es2016",
      "dom"
    ],
    "outDir": "../out-tsc/app",
    "target": "es5",
    "module": "es2015",
    "baseUrl": "",
    "types": []
  },
  "exclude": [
    "test.ts",
    "**/*.spec.ts"
  ]
}

With this config, we can use the ng serve with aot:
"start": "ng serve --aot --proxy-config proxy.conf.json"

If anybody was able to get here...
In my case it was some error in CSS file connected with one of components. Just removed bug and it works.

update npm install [email protected]
for me it's working fine

This was a frustrating one... Especially since I had this issue months ago, solved it and then totally forgot the fix and then saw it pop up again in another project.

In my case neither upgrading the CLI or installing enhanced resolve 3.3.0 fixed the issue.

For me it was simply a casing issue. All of our apps are kept under an 'Apps' folder, but in both my Webpack entry and ngtools aot entryModule, I had the folder in lowercase as 'apps'.

Hopefully that helps someone else and also future me :)

I am working on an app based on the ASP.NET Core Angular template, which does not come with AngularCLI. I had this error only on publishing the solution, without no other information. Turns out I moved the app.browser.module.ts and app.server.module.ts files from the app folder to app/modules and I forgot to update the new entryModule paths (thanks @tenderloin420 ) in the AngularCompilerPlugin/AotPlugin sections in webpack.config.js. The publishing worked once I corrected the paths.

Still facing the same error, update the "enhanced-resolve" seems work, and the "ng build --env=prod --output-hashing" will build different outputs, which is much bigger than the "ng build --prod" output, that is not our expect.

I've updated to
"@angular/cli": "^1.4.10",
"@angular/compiler-cli": "^4.2.6",
and problem was fixed.

Currently using:
/ \ _ __ __ _ _ _| | __ _ _ __ / ___| | |_ _|
/ △ \ | '_ \ / _| | | | |/ _ | '__| | | | | | |
/ ___ \| | | | (_| | |_| | | (_| | | | |___| |___ | |
/_/ __| |_|__, |__,_|_|__,_|_| ____|_____|___|
|___/

Angular CLI: 1.7.4
Node: 8.9.0
OS: win32 x64
Angular: 5.1.0
... animations, common, compiler, compiler-cli, core, forms
... http, language-service, platform-browser
... platform-browser-dynamic, router

@angular/cdk: 5.2.5
@angular/cli: 1.7.4
@angular/material: 5.2.5
@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.5.3
webpack: 3.11.0

BUT while doing AOT build it is giving me following error help required!
Thanks!

screenshot_4

@KhizerRehan same CLI v1.7.4 here, the only major difference being the operating system (Fedora 28).

If I'm not mistaken, this is the latest v1.* series launched to this day, but the bug persists.

Same here, in August. Any ideas?

Check your tsconfig:
"angularCompilerOptions": {
"entryModule": "src/app/app.server.module#AppServerModule"
}

entryModule should have proper app module path

`` _ _ ____ _ ___ / \ _ __ __ _ _ _| | __ _ _ __ / ___| | |_ _| / △ \ | '_ \ / _ | | | | |/ _` | '__| | | | | | |
/ ___ \| | | | (_| | |_| | | (_| | | | |___| |___ | |
/_/ __| |_|__, |__,_|_|__,_|_| ____|_____|___|
|___/
@angular/cli: 1.2.6
node: 8.11.1
os: win32 x64
@angular/animations: 4.4.7
@angular/common: 4.4.7
@angular/compiler: 4.4.7
@angular/core: 4.4.7
@angular/forms: 4.4.7
@angular/http: 4.4.7
@angular/platform-browser: 4.4.7
@angular/platform-browser-dynamic: 4.4.7
@angular/router: 4.4.7
@angular/cli: 1.2.6
@angular/compiler-cli: 4.4.7
@angular/language-service: 4.4.7

I executed this command `ng build --prod` and the error was: 

ERROR in Metadata version mismatch for module F://node_modules/@ng-select/ng-select/ng-select.d.ts, found version 4, expected 3, resolving symbol AppModule in F://src/app/app.module.ts, resolving symbol AppModule in F:/*/src/app/app.module.ts
(node:17688) DeprecationWarning: Chunk.modules is deprecated. Use Chunk.getNumberOfModules/mapModules/forEachModule/containsModule instead.
```

`

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

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

Still problem is going on ...

ERROR in ./src/main.ts
Module not found: Error: Can't resolve './$$_gendir/app/app.module.ngfactory' in '/home/user/Server/v2/Battery-Server-Panel/src'
 @ ./src/main.ts 3:0-74
 @ multi ./src/main.ts

Check this https://github.com/angular/angular-cli/issues/11835#issuecomment-419097658 update to @angular/core 6.1.7

Check this #11835 (comment) update to @angular/core 6.1.7

project is based on angular 4

Check this #11835 (comment) update to @angular/core 6.1.7

project is based on angular 4

Then upgrade? 4 vs 6 isn't that hard aside from a few breaking changes with rxjs that can be fixed with just installing rxjs-compat. I just finished migrating an old project running in production made in v4 to v6 in less than a week. I know it's not the solution, but the fix is working in v6.

May be your angular version is grater than 4.0.0 because of don't work
properly this command.
please check your version.

On Wed, Sep 26, 2018 at 3:13 AM DARKGuy (Alemar) notifications@github.com
wrote:

Check this #11835 (comment)
https://github.com/angular/angular-cli/issues/11835#issuecomment-419097658
update to @angular/core 6.1.7

project is based on angular 4

Then upgrade? 4 vs 6 isn't that hard aside from a few breaking changes
with rxjs that can be fixed with rxjs-compat. I just finished migrating an
old project running in production made in v4 to v6 in less than a week.


You are receiving this because you commented.
Reply to this email directly, view it on GitHub
https://github.com/angular/angular-cli/issues/4551#issuecomment-424503263,
or mute the thread
https://github.com/notifications/unsubscribe-auth/AoS6xHrNo0XmHbIlkPobxqgLdhM9EXRTks5uepx0gaJpZM4L7u-Y
.

May be your angular version is grater than 4.0.0 because of don't work
properly this command.
please check your version.

On Wed, Sep 26, 2018 at 2:00 AM matinzd77 notifications@github.com wrote:

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

Still problem is going on ...

ERROR in ./src/main.ts
Module not found: Error: Can't resolve './$$_gendir/app/app.module.ngfactory' in '/home/user/Server/v2/Battery-Server-Panel/src'
@ ./src/main.ts 3:0-74
@ multi ./src/main.ts


You are receiving this because you commented.
Reply to this email directly, view it on GitHub
https://github.com/angular/angular-cli/issues/4551#issuecomment-424480699,
or mute the thread
https://github.com/notifications/unsubscribe-auth/AoS6xG2E1cUiC2CFJbyXUoZ4DQvVKElfks5ueotSgaJpZM4L7u-Y
.

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.

+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.

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

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

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

For me it worked with this solution.

/ \ _ __ __ _ _ _| | __ _ _ __ / ___| | |_ _|
/ △ \ | '_ \ / _| | | | |/ _ | '__| | | | | | |
/ ___ \| | | | (_| | |_| | | (_| | | | |___| |___ | |
/_/ __| |_|__, |__,_|_|__,_|_| ____|_____|___|
|___/
@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 please read all the comments asap

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?

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

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

@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\gazalaDesktop\GCDB_Workspace\GCDB6-Portal-Final\src'
@ ./src/main.ts 5:0-74
@ multi ./src/main.ts

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

image

angular 7 to 8 update face issue

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

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

worked for me too

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._

Was this page helpful?
0 / 5 - 0 ratings