Angular-cli: ng serve --aot fail after file change

Created on 9 Aug 2018  Â·  67Comments  Â·  Source: angular/angular-cli

Bug Report or Feature Request (mark with an x)

- [X] bug report -> please search issues before submitting
- [ ] feature request

Command (mark with an x)

- [ ] new
- [ ] build
- [x] serve
- [ ] test
- [ ] e2e
- [ ] generate
- [ ] add
- [ ] update
- [ ] lint
- [ ] xi18n
- [ ] run
- [ ] config
- [ ] help
- [ ] version
- [ ] doc

Versions

Angular CLI: 6.1.2
Node: 10.0.0
OS: win32 x64
Angular: 6.1.2
... animations, cli, common, compiler, compiler-cli, core, forms
... http, language-service, platform-browser
... platform-browser-dynamic, platform-server, router
... service-worker

Package Version

@angular-devkit/architect 0.7.2
@angular-devkit/build-angular 0.7.2
@angular-devkit/build-optimizer 0.7.2
@angular-devkit/build-webpack 0.7.2
@angular-devkit/core 0.7.2
@angular-devkit/schematics 0.7.2
@angular/cdk 6.4.3
@angular/material 6.4.3
@ngtools/webpack 6.1.2
@schematics/angular 0.7.2
@schematics/update 0.7.2
rxjs 6.2.2
typescript 2.9.2
webpack 4.9.2
-->

Repro steps

  1. run ng serve with aot flag
  2. change something in watch filles
  3. see error in module find(file that change)

The log given by the failure

``` ERROR in ./src/homeapp/app/components/reports/profitAndLoss/profit.and.loss.ngfactory.js
Module not found: Error: Can't resolve '@angular/material/button.ngfactory' in 'D:\Flare\flare.ui2\src\homeapp\app\components\reports\profitAndLoss'
ERROR in ./src/homeapp/app/components/reports/profitAndLoss/profit.and.loss.ngfactory.js
Module not found: Error: Can't resolve '@angular/material/checkbox.ngfactory' in 'D:\Flare\flare.ui2\src\homeapp\app\components\reports\profitAndLoss'
ERROR in ./src/homeapp/app/components/reports/profitAndLoss/profit.and.loss.ngfactory.js
Module not found: Error: Can't resolve '@angular/material/form-field.ngfactory' in '.\src\homeapp\app\components\reports\profitAndLoss'
ERROR in ./src/homeapp/app/components/reports/profitAndLoss/profit.and.loss.ngfactory.js
Module not found: Error: Can't resolve '@angular/material/menu.ngfactory' in '.\src\homeapp\app\components\reports\profitAndLoss'

Date: 2018-08-09T17:57:03.581Z - Hash: 12b8572033feade48d1a - Time: 34472ms
4 unchanged chunks
chunk {main} main.js (main) 16.2 MB [initial] [rendered]

i ï½¢wdmï½£: Failed to compile.

```

Desired functionality

work as before update

Mention any other details that might be useful

I didn't know where to write, in @angular/compile or here but error showed in cli, so...
This breaking from this fix https://github.com/angular/angular/pull/25335.
Reverting @angular/compiler to 6.1.1 workaround for this.
I tested without fix, it work as before.

devkibuild-angular high regression bufix

Most helpful comment

Added to the top of our backlog

All 67 comments

the same, v6.1.2 is broken.
downgrade to
"@angular/compiler-cli": "6.1.1",

I have exactly the same problem, and reverting @angular/compiler "fixes" the problem.

Hey,

This issue can also reproduce as follows:

Steps:

ng new ngApp --routing && cd ngApp
ng serve --aot
change a file under watch

Error:

ERROR in ./src/app/app.module.ngfactory.js
Module not found: Error: Can't resolve '@angular/router.ngfactory' in '/Users/vchimev/Work/tmp/ngApp/src/app'
ℹ 「wdm」: Failed to compile.

Causes https://github.com/NativeScript/nativescript-dev-webpack/issues/630.

I have exactly the same problem with Angular CLI: 6.1.3

Added to the top of our backlog

I was unable to replicate this with the following versions. Can you try with the versions listed below? For existing projects, please ensure that @angular-devkit/build-angular is updated; upgrading the CLI does not automatically update @angular-devkit/build-angular.

Angular CLI: 6.1.3
Node: 8.9.4
OS: darwin x64
Angular: 6.1.2
... animations, common, compiler, compiler-cli, core, forms
... http, language-service, platform-browser
... platform-browser-dynamic, router

Package                           Version
-----------------------------------------------------------
@angular-devkit/architect         0.7.3
@angular-devkit/build-angular     0.7.3
@angular-devkit/build-optimizer   0.7.3
@angular-devkit/build-webpack     0.7.3
@angular-devkit/core              0.7.3
@angular-devkit/schematics        0.7.3
@angular/cli                      6.1.3
@ngtools/webpack                  6.1.3
@schematics/angular               0.7.3
@schematics/update                0.7.3
rxjs                              6.2.2
typescript                        2.7.2
webpack                           4.9.2

@clydin i used this:

Angular CLI: 6.1.3
Node: 10.8.0
OS: win32 x64(windows 10)
Angular: 6.1.2
... animations, common, compiler, compiler-cli, core, forms
... http, language-service, platform-browser
... platform-browser-dynamic, platform-server, router
... service-worker

Package                           Version
-----------------------------------------------------------
@angular-devkit/architect         0.7.3
@angular-devkit/build-angular     0.7.3
@angular-devkit/build-optimizer   0.7.3
@angular-devkit/build-webpack     0.7.3
@angular-devkit/core              0.7.3
@angular-devkit/schematics        0.7.3
@angular/cdk                      6.4.3
@angular/cli                      6.1.3
@angular/material                 6.4.3
@ngtools/webpack                  6.1.3
@schematics/angular               0.7.3
@schematics/update                0.7.3
rxjs                              6.2.2
typescript                        2.9.2
webpack                           4.9.2

also i used ng server without bazel,
same error when updated.

my tsconfig

{
  "compilerOptions": {
    "baseUrl": "",
    "declaration": false,
    "emitDecoratorMetadata": true,
    "experimentalDecorators": true,
    "listEmittedFiles":true,
    "lib": ["es6", "dom", "es2016.array.include"],
    "mapRoot": "./",
    "module": "es6",
    "moduleResolution": "node",
    "outDir": "../dist/out-tsc",
    "sourceMap": false,
    "target": "es5",
    "alwaysStrict": true,
    "typeRoots": [
      "../node_modules/@types"
    ]
  },
  "angularCompilerOptions": {
    "preserveWhitespaces": false
  }
}

serve config

  "serve": {
          "builder": "@angular-devkit/build-angular:dev-server",
          "options": {
            "browserTarget": "homeapp:build"
          },
          "configurations": {
            "production": {
              "browserTarget": "homeapp:build:production"
            }
          }
        },

command : ng serve --aot --source-map=false
it happen time to time just change file few times. U will see it.

As a test, every watched file in a new project was changed twice with both TS 2.7.2 and TS 2.9.2; and was unable to reproduce. Two files were also changed 5 times each (a component and a module) with the same outcome. To fully diagnose the issue, a minimal reproduction or exact steps to trigger the issue will be needed in light of the inability to reproduce.

@clydin can u try this https://github.com/angular/angular-cli/issues/11835#issuecomment-412009587,
u changed file while server active?

Thanks. Traced the issue to this PR in angular itself: https://github.com/angular/angular/pull/25335
This change was introduced within @angular/compiler in version 6.1.2.

Same issue confirmed, and the only solution for AOT so far is back to use 6.1.1

any progress?
With this i can`t test angular 7 beta

For me this issue even with 6.1.1 (6.1.0 all was fine)

@deerua Can you share your package.json to see if any conflicts?

Sure


  "dependencies": {
    "@angular/animations": "^6.1.1",
    "@angular/cdk": "^6.4.1",
    "@angular/common": "^6.1.1",
    "@angular/compiler": "^6.1.1",
    "@angular/core": "^6.1.1",
    "@angular/forms": "^6.1.1",
    "@angular/http": "^6.1.1",
    "@angular/material": "^6.4.1",
    "@angular/platform-browser": "^6.1.1",
    "@angular/platform-browser-dynamic": "^6.1.1",
    "@angular/platform-server": "^6.1.1",
    "@angular/router": "^6.1.1",
    "@ngrx/core": "^1.2.0",
    "@ngrx/effects": "^6.0.1",
    "@ngrx/router-store": "^6.0.1",
    "@ngrx/store": "^6.0.1",
    "@ngrx/store-devtools": "^6.0.1",
    "@nguniversal/common": "6.0.0",
    "@nguniversal/express-engine": "6.0.0",
    "@nguniversal/module-map-ngfactory-loader": "6.0.0",
    "@ngx-translate/core": "10.0.2",
    "@ngx-translate/http-loader": "^3.0.1",
    "@types/angular": "1.6.45",
    "@types/cheerio": "^0.22.7",
    "@types/compression": "0.0.36",
    "@types/googlemaps": "^3.30.8",
    "angular-calendar": "0.25.1",
    "cheerio": "^1.0.0-rc.2",
    "compression": "^1.7.2",
    "core-js": "2.5.1",
    "cross-env": "https://registry.npmjs.org/cross-env/-/cross-env-5.1.4.tgz",
    "date-fns": "1.29.0",
    "express-winston": "latest",
    "hammerjs": "2.0.8",
    "immer": "^1.5.0",
    "jasmine-console-reporter": "^3.0.2",
    "karma-failed-reporter": "0.0.3",
    "localize-router": "https://github.com/manzonif/temp-localize-router/archive/a45b7b3f1eebfe82e3093e0b6cd5bb00612e9bb6.tar.gz",
    "mobile-detect": "1.4.1",
    "ngrx-store-localstorage": "5.0.1",
    "ngx-lazy-load-images": "^1.3.1",
    "ngx-translate-parser-plural-select": "1.1.3",
    "preboot": "6.0.0-beta.4",
    "request": "^2.83.0",
    "rxjs": "^6.2.2",
    "rxjs-tslint": "^0.1.5",
    "ts-action": "^6.0.2",
    "ts-action-operators": "^7.0.0",
    "ts-loader": "^4.4.2",
    "ts-md5": "^1.2.4",
    "winston": "^2.4.0",
    "zone.js": "^0.8.26"
  },
  "devDependencies": {
    "@angular-devkit/build-angular": "^0.7.3",
    "@angular/cli": "^6.1.1",
    "@angular/compiler-cli": "^6.1.1",
    "@angular/flex-layout": "^6.0.0-beta.17",
    "@angular/language-service": "^6.1.1",
    "@compodoc/compodoc": "1.1.3",
    "@ngrx/schematics": "^6.0.1",
    "@storybook/addon-notes": "4.0.0-alpha.14",
    "@storybook/addon-options": "4.0.0-alpha.14",
    "@storybook/addon-viewport": "4.0.0-alpha.14",
    "@storybook/addons": "4.0.0-alpha.14",
    "@storybook/angular": "4.0.0-alpha.14",
    "@types/express": "^4.11.1",
    "@types/express-winston": "^2.4.0",
    "@types/hammerjs": "2.0.34",
    "@types/jasmine": "2.5.38",
    "@types/lodash": "^4.14.95",
    "@types/node": "6.0.60",
    "@types/request": "^2.47.0",
    "@types/storybook__addon-notes": "^3.3.1",
    "angular-playground": "1.7.1",
    "babel-core": "^6.26.0",
    "codelyzer": "4.2.1",
    "concurrently": "^3.5.1",
    "enhanced-resolve": "3.3.0",
    "jasmine-core": "2.5.2",
    "jasmine-marbles": "^0.3.1",
    "jasmine-spec-reporter": "3.2.0",
    "karma": "1.7.1",
    "karma-chrome-launcher": "2.2.0",
    "karma-cli": "1.0.1",
    "karma-coverage-istanbul-reporter": "1.3.0",
    "karma-jasmine": "1.1.0",
    "karma-jasmine-html-reporter": "0.2.2",
    "karma-verbose-reporter": "0.0.6",
    "localstorage-polyfill": "^1.0.1",
    "node-pre-gyp": "0.6.39",
    "node-sass": "4.9.2",
    "rxjs-compat": "^6.2.2",
    "rxjs-tslint-rules": "^3.9.0",
    "sass-lint": "1.12.1",
    "source-map-explorer": "1.5.0",
    "ts-node": "4.1.0",
    "tslint": "5.9.1",
    "tslint-eslint-rules": "4.1.1",
    "typescript": "^2.9.0",
    "webpack-bundle-analyzer": "2.9.1",
    "webpack-cli": "^3.0.8"
  },

After some changes we have 183 ERRORS
Most of it

Module not found: Error: Can't resolve '@angular/router.ngfactory' 

and all material components

^6.1.1 means install the latest version of 6.x (with a minimum of 6.1.1) which would be 6.1.2

As a temporary workaround, you can fix @angular/compiler to 6.1.1 (note you will receive peer dependency warnings). You can also stay on Angular 6.1.1 as a whole until a fix is available. Also when building for production, moving to consistent versions would be advised (i.e., all 6.1.1 or all 6.1.2).

Note also that CLI and @angular-devkit/build-angular can be at their latest version.

thx @clydin
i have checked node_modules manually before and all the deps. was 6.1.1 :) in package.json, strange
but after strict version all become fine (looks like)

The same issue after update to 6.1.2.
Downgrade to 6.1.1 helped

Been fighting with this for about a week now. I can confirm this package.json fixes all issues (made with npm i -g @angular/[email protected] then manually edited):

{
  "name": "admin",
  "version": "0.0.0",
  "scripts": {
    "ng": "ng",
    "start": "ng serve --aot",
    "build": "ng build --aot --prod"
  },
  "private": true,
  "dependencies": {
    "@angular/animations": "6.1.1",
    "@angular/common": "6.1.1",
    "@angular/compiler": "6.1.1",
    "@angular/core": "6.1.1",
    "@angular/forms": "6.1.1",
    "@angular/http": "6.1.1",
    "@angular/platform-browser": "6.1.1",
    "@angular/platform-browser-dynamic": "6.1.1",
    "@angular/router": "6.1.1",
    "core-js": "^2.5.4",
    "rxjs": "^6.0.0",
    "zone.js": "~0.8.26"
  },
  "devDependencies": {
    "@angular-devkit/build-angular": "0.7.0",
    "@angular/cli": "6.1.1",
    "@angular/compiler-cli": "6.1.1",
    "@angular/language-service": "6.1.1",
    "@types/node": "~8.9.4",
    "ts-node": "~5.0.1",
    "tslint": "~5.9.1",
    "typescript": "~2.7.2"
  }
}

is the problem fixed in @angular/[email protected]?

It wasn't fixed in 6.1.3. I just checked it.

Still not fixed with 6.1.4 right?

This problem wasn't fixed in 6.1.4
I have this in @angular/cli >= 6.1.0

We're looking at this issue at the moment.

Steps to reproduce:

  • create a new project ng new repro-proj
  • make sure you're using at least @angular/[email protected] or above
  • add RouterModule to src/app/app.module.ts:
import { BrowserModule } from '@angular/platform-browser';
import { NgModule } from '@angular/core';
import { RouterModule } from '@angular/router';

import { AppComponent } from './app.component';
import { environment } from '../environments/environment';

@NgModule({
  declarations: [
    AppComponent
  ],
  imports: [
    BrowserModule,
    RouterModule,
  ],
  providers: [],
  bootstrap: [AppComponent]
})
export class AppModule { }
  • run ng serve --aot
  • save src/app/app.module.ts (no change in it needed)
  • see the following error:
ERROR in ./src/app/app.module.ngfactory.js
Module not found: Error: Can't resolve '@angular/router.ngfactory' in 'D:\sandbox\latest-project\src\app'

This problem seems to have been introduced in https://github.com/angular/angular/pull/25335, and is the same as reported in https://github.com/angular/angular/issues/25424.

I inspected the contents of src/app/app.module.ngfactory.js and what happens is that in the initial build it contains this import:

import * as i3 from "../../node_modules/@angular/router/router.ngfactory";

but in the rebuild the import is changed to

import * as i3 from "@angular/router.ngfactory";

I checked if the same happens happens with just ngc, and it doesn't.

Still investigating further.

i'm experiencing this same problem with 6.1.0

@elmartino
This is weird, please share your package.json.

@elmartino
I see, it seems you are no using exactly 6.1.0, please follow the instruction at https://github.com/angular/angular-cli/issues/11835#issuecomment-413262460

Had some trouble with the JSON markup, but you saw it already :-) changing "@angular/compiler": "^6.1.0", to "@angular/compiler": "6.1.0", working now. Thanks!

@filipesilva Would it be possible to cover this with integration tests in the future, given that it is very easy to reproduce?

This appears to be fixed by the Angular 6.1.6 release today.

I confirm that this issued is fixed in Angular v6.1.6.

When will be the NPM release?

@rickvandermeij-aanzee yesterday.

didn't notice the fix is at @angular/compiler-cli

@rickvandermeij-aanzee because it's in angular, not cli.

I'm still getting this issue on both @6.1.0 and @6.1.6. Both @angular/compiler and @angular/compiler-cli were set to those versions. Is anyone else still experiencing this?

@jgf5013 nope, since 6.1.6 everything works fine for me.

@jgf5013 make sure that you have the latest versions specified, then delete node_modules folder and do an npm install.

Hmm, still no luck. Cleared out node_modules folder and re-ran npm install. Checked the installed versions of @angular/compiler and @angular/compiler-cli directly in their package.json files and confirmed both are set to 6.1.6. Also tried updating to @latest for these two deps. which updated them to 6.1.7 but the issue was still there.

Just to be clear, I can build and serve the app without issue using ng serve <appname> and ng build <appname> commands but both ng serve <appname> --aot and ng build <appname> --prod fail.

Could it make a difference that the app is a hybrid Angular/AngularJS app?

package.json file below...

{
  "name": "appname",
  "version": "0.0.0",
  "scripts": {
    "ng": "ng",
    "start": "ng serve",
    "build": "ng build",
    "test": "ng test",
    "lint": "ng lint",
    "e2e": "ng e2e",
    "prettier:write": "prettier --write \"projects/**/*.ts\""
  },
  "private": true,
  "dependencies": {
    "@angular/animations": "^6.1.6",
    "@angular/cdk": "^6.4.3",
    "@angular/common": "^6.1.6",
    "@angular/core": "^6.1.6",
    "@angular/forms": "^6.1.6",
    "@angular/http": "^6.1.6",
    "@angular/material": "^6.4.4",
    "@angular/platform-browser": "^6.1.6",
    "@angular/platform-browser-dynamic": "^6.1.6",
    "@angular/router": "^6.1.6",
    "@angular/upgrade": "^6.1.6",
    "@ngrx/effects": "^6.1.0",
    "@ngrx/entity": "^6.1.0",
    "@ngrx/router-store": "^6.1.0",
    "@ngrx/store": "^6.1.0",
    "@ngrx/store-devtools": "^6.1.0",
    "@types/angular": "^1.6.50",
    "@uirouter/angular-hybrid": "^6.0.2",
    "angular": "^1.7.3",
    "angular-file-upload": "^2.5.0",
    "angular-smart-table": "^2.1.11",
    "angular-strap": "^2.3.12",
    "angular-toastr": "^2.1.1",
    "angular-ui-grid": "^4.6.3",
    "bootstrap": "^4.1.3",
    "core-js": "^2.5.4",
    "d3": "^3.5.10",
    "font-awesome": "^4.7.0",
    "jquery": "^3.3.1",
    "papaparse": "^4.6.0",
    "ramda": "^0.25.0",
    "rx-angular": "^1.1.3",
    "rxjs": "^6.0.0",
    "ui-select": "^0.19.8",
    "zone.js": "~0.8.26"
  },
  "devDependencies": {
    "@angular-devkit/build-angular": "^0.7.5",
    "@angular/cli": "^6.1.5",
    "@angular/compiler": "^6.1.6",
    "@angular/compiler-cli": "^6.1.6",
    "@angular/language-service": "6.1.6",
    "@ngrx/schematics": "^6.1.0",
    "@types/jasmine": "~2.8.6",
    "@types/jasminewd2": "~2.0.3",
    "@types/node": "~8.9.4",
    "codelyzer": "~4.2.1",
    "jasmine-core": "~2.99.1",
    "jasmine-spec-reporter": "~4.2.1",
    "karma": "~1.7.1",
    "karma-chrome-launcher": "~2.2.0",
    "karma-coverage-istanbul-reporter": "~2.0.0",
    "karma-jasmine": "~1.1.1",
    "karma-jasmine-html-reporter": "^0.2.2",
    "node-sass": "^4.9.3",
    "prettier": "^1.14.2",
    "protractor": "~5.3.0",
    "ts-node": "~5.0.1",
    "tslint": "~5.9.1",
    "typescript": "~2.9.2"
  }
}

Just now reading through the docs on compiling hybrid apps... yea, seems like issue for me is due to missed steps in configuration for aot/hybrid app - namely that arrow functions can't be used. Thanks for the feedback all!

This was angular core issue and fixed in @angular/core 6.1.7

I am still getting the Module not found Error.

node 10.11.0
npm 6.4.1

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

    "@angular/cli": "~6.2.3",
    "@angular/compiler-cli": "^6.1.8",
    "@angular/language-service": "^6.1.8",

I also still have problems with angular 6.1.9

"@angular/animations": "6.1.9",
"@angular/cdk": "^6.4.2",
"@angular/common": "6.1.9",
"@angular/compiler": "6.1.9",
"@angular/core": "6.1.9",
"@angular/flex-layout": "^6.0.0-beta.17",
"@angular/forms": "6.1.9",
"@angular/http": "6.1.9",
"@angular/material": "^6.4.2",
"@angular/material-moment-adapter": "^6.4.2",
"@angular/platform-browser": "6.1.9",
"@angular/platform-browser-dynamic": "6.1.9",
"@angular/router": "6.1.9",
"ajv": "^6.5.2",
"angular-in-memory-web-api": "^0.6.0",
"bootstrap": "^4.1.0",
"core-js": "^2.5.5",
"d3-ng2-service": "^2.2.0",
"hammerjs": "^2.0.8",
"jquery": "^3.3.1",
"lodash": "^4.17.5",
"moment": "^2.22.2",
"node-sass": "^4.9.2",
"popper.js": "^1.14.3",
"pump": "^2.0.1",
"rxjs": "^6.3.3",
"rxjs-compat": "^6.2.1",
"zone.js": "~0.8.26"
},
"devDependencies": {
"@angular-devkit/build-angular": "~0.6.8",
"@angular/cli": "^6.1.2",
"@angular/compiler-cli": "6.1.9",
"@angular/language-service": "6.1.9",
"@types/hammerjs": "^2.0.35",
"@types/jasmine": "^2.8.6",
"@types/jasminewd2": "~2.0.2",
"@types/node": "^9.4.7",
"codelyzer": "^4.2.1",
"igniteui-angular": "^6.1.0",
"jasmine-core": "~2.9.1",
"jasmine-spec-reporter": "~4.2.1",
"karma": "^2.0.5",
"karma-chrome-launcher": "~2.2.0",
"karma-cli": "~1.0.1",
"karma-coverage-istanbul-reporter": "^1.4.2",
"karma-jasmine": "^1.1.2",
"karma-jasmine-html-reporter": "^0.2.2",
"protractor": "^5.3.1",
"ts-node": "~4.1.0",
"tslint": "~5.9.1",
"typescript": "^2.9.0"

@Charlyo @Andrii-A Did you check whether you've installed angular as a global package and if it's upgraded to 6.x?

npm ls --global --depth=0

@Charlyo @Andrii-A Did you check whether you've installed angular as a global package and if it's upgraded to 6.x?

npm ls --global --depth=0

This is the output that I get

/usr/local/lib
├── @angular/[email protected]
├── [email protected] -> /Users/charlyo/ANIS/interface
└── [email protected]

npm ERR! peer dep missing: @angular/core@^5.0 || ^4.0 || ^2.0, required by [email protected]
npm ERR! peer dep missing: typescript@~2.4.0 || ~2.5.0 || ~2.6.0 || ~2.7.0, required by @ngtools/[email protected]

Same here (Angular 6.1.10):

$ ng -v

     _                      _                 ____ _     ___
    / \   _ __   __ _ _   _| | __ _ _ __     / ___| |   |_ _|
   / â–³ \ | '_ \ / _` | | | | |/ _` | '__|   | |   | |    | |
  / ___ \| | | | (_| | |_| | | (_| | |      | |___| |___ | |
 /_/   \_\_| |_|\__, |\__,_|_|\__,_|_|       \____|_____|___|
                |___/


Angular CLI: 6.2.4
Node: 8.11.1
OS: win32 x64
Angular: 6.1.10

Ouput:

i ï½¢wdmï½£: Compiled successfully.
i ï½¢wdmï½£: Compiling...
C:\PROJECT_PATH\node_modules\enhanced-resolve\lib\CachedInputFileSystem.js:92
                                        throw data[0];
                                        ^

Error: ENOENT: no such file or directory, stat 'C:\PROJECT_PATH\src\app\@shared\sr-only\sr-only.component.ngfactory.js'
    at Object.fs.statSync (fs.js:948:11)

Workaround [email protected]
Workaround [email protected]

I have the same issue with [email protected] and [email protected]

It fails with error
Error: ENOENT: no such file or directory, stat '/Users/sergeyf/job/case-management-frontend/src/app/shared/components/cost-center-image/cost-center-image.component.ngfactory.js'

What's unusual here we use an inline template, not standalone. Might be this a problem?

https://github.com/angular/angular-cli/issues/12260#issuecomment-429831070 this helped me out

In our case, we were optimizing the ng serve which threw similar error message.

Instead of:

           "dev": {
              "fileReplacements": [
                {
                  "replace": "src/environments/environment.ts",
                  "with": "src/environments/environment.dev.ts"
                }
              ],
              "optimization": false,
              "outputHashing": "all",
              "sourceMap": false,
              "extractCss": true,
              "namedChunks": false,
              "aot": true,
              "extractLicenses": true,
              "vendorChunk": false,
              "buildOptimizer": true
            },

Use:

           "localdev": {
              "fileReplacements": [
                {
                  "replace": "src/environments/environment.ts",
                  "with": "src/environments/environment.localdev.ts"
                }
              ]
            }

ERROR in ./src/main.ts
Module not found: Error: Can't resolve './$$_gendir/app/app.module.ngfactory' in 'D:\2019\DCubeBillingSystem\DCubeHotelSystem\app\src'
ERROR in Error: Cannot determine the module for class ReportDashboardComponent in D:/2019/DCubeBillingSystem/DCubeHotelSystem/app/src/app/components/ReportDashboard/reportdashboard.component.ts! Add ReportDashboardComponent to the NgModule to fix it.

Issue still exists when ng build --aot.
Issue still exists when ng serve --aot.

Angular CLI: 7.3.2
Node: 10.0.0
OS: darwin x64
Angular: 7.2.5
... animations, common, compiler, compiler-cli, core, forms
... http, language-service, platform-browser
... platform-browser-dynamic, router

Package                           Version
-----------------------------------------------------------
@angular-devkit/architect         0.13.2
@angular-devkit/build-angular     0.13.2
@angular-devkit/build-optimizer   0.13.2
@angular-devkit/build-webpack     0.13.2
@angular-devkit/core              7.3.2
@angular-devkit/schematics        7.3.2
@angular/cli                      7.3.2
@ngtools/webpack                  7.3.2
@schematics/angular               7.3.2
@schematics/update                0.13.2
rxjs                              6.4.0
typescript                        3.2.4
webpack                           4.29.0

I have the same issue as @artuska with the same specs.

Angular CLI: 7.3.3
Node: 8.12.0
OS: win32 x64
Angular: 7.2.6
... animations, common, compiler, compiler-cli, core, forms
... http, language-service, platform-browser
... platform-browser-dynamic, router

Package                           Version
-----------------------------------------------------------
@angular-devkit/architect         0.13.3
@angular-devkit/build-angular     0.13.3
@angular-devkit/build-optimizer   0.13.3
@angular-devkit/build-webpack     0.13.3
@angular-devkit/core              0.7.5
@angular-devkit/schematics        0.7.5
@angular/cdk                      7.3.3
@angular/cli                      7.3.3
@angular/flex-layout              7.0.0-beta.23
@angular/material                 7.3.3
@ngtools/json-schema              1.1.0
@ngtools/webpack                  7.3.3
@schematics/angular               7.3.3
@schematics/update                0.13.3
ng-packagr                        4.7.1
rxjs                              6.4.0
typescript                        3.2.4
webpack                           4.29.0

@JWBrownie If you have this type of error probably you have upgraded from Angular 5 to 6 or 7.

Replace "rootDir": "./src", in your tsconfig.json file to "rootDir": "./", or just remove this parameter completely.

@artuska VERIFIED. Worked for me. Thank you from NYC.

Still having this issue on Angular 7.2
Only with ng build or serve --aot or --prod, I get: .ngfactory.js Module not found
Any help? I see a 'fixed by Ivy' tag applied - would I have to wait for Ivy?

@andrewantar try removing optimization flags in angular.json

@gatsbyz Set them to false and also tried removing the params, and still same error..

@andrewantar And you've tried removing this from your tsconfig.json -> "rootDir": "./src"

If your tsconfig.json has this path. remove and try it. It worked for me.

"paths": { "@angular/*": ["../node_modules/@angular/*"] },

If your tsconfig.json has this path. remove and try it. It worked for me.

"paths": { "@angular/*": ["../node_modules/@angular/*"] },

It works like black magic mate!!!!!!!

I am still getting error in Angular 7.2.15 while building using --aot flag. Normal build is working fine.
The error message looks like:

ERROR in src\app\Test.component.html(6,8): : Property 'sort' does not exist on type 'TestComponent'.

src\app\Test.component.html(3,74): : Property 'allowUnsort' does not exist on type 'TestComponent'.

It is not recognizing any of the kendo grid properties. My kendo grid html looks like this:

<kendo-grid #grid [kendoGridBinding]="gridData | async" [pageSize]="10" [pageable]="true" [filterable]="true"
  [groupable]="true" [resizable]="true" [reorderable]="true" [filterable]="true" [columnMenu]="true"
  [rowClass]="rowCallback" (dataStateChange)="onDataStateChange($event)" [sortable]="{
    allowUnsort: allowUnsort,
    mode: multiple ? 'multiple' : 'single'
    }" [sort]="sort" (sortChange)="sortChange($event)">

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