angular-cli: JIT is ok, use AOT failed

ng serve --aot --port 9000 --host 0.0.0.0

ERROR in ./src/main.ts
Module not found: Error: Can't resolve './app/app.module.ngfactory' in '/Users/xujin/My_Projects/CSharp/antme-uwp/antme/antme-uwp-web/src'
resolve './app/app.module.ngfactory' in '/Users/xujin/My_Projects/CSharp/antme-uwp/antme/antme-uwp-web/src'
  using description file: /Users/xujin/My_Projects/CSharp/antme-uwp/antme/antme-uwp-web/package.json (relative path: ./src)
    Field 'browser' doesn't contain a valid alias configuration
  after using description file: /Users/xujin/My_Projects/CSharp/antme-uwp/antme/antme-uwp-web/package.json (relative path: ./src)
    using description file: /Users/xujin/My_Projects/CSharp/antme-uwp/antme/antme-uwp-web/package.json (relative path: ./src/app/app.module.ngfactory)
      no extension
        Field 'browser' doesn't contain a valid alias configuration
        /Users/xujin/My_Projects/CSharp/antme-uwp/antme/antme-uwp-web/src/app/app.module.ngfactory doesn't exist
      .ts
        Field 'browser' doesn't contain a valid alias configuration
        /Users/xujin/My_Projects/CSharp/antme-uwp/antme/antme-uwp-web/src/app/app.module.ngfactory.ts doesn't exist
      .js
        Field 'browser' doesn't contain a valid alias configuration
        /Users/xujin/My_Projects/CSharp/antme-uwp/antme/antme-uwp-web/src/app/app.module.ngfactory.js doesn't exist
      as directory
        /Users/xujin/My_Projects/CSharp/antme-uwp/antme/antme-uwp-web/src/app/app.module.ngfactory doesn't exist
[/Users/xujin/My_Projects/CSharp/antme-uwp/antme/antme-uwp-web/src/app/app.module.ngfactory]
[/Users/xujin/My_Projects/CSharp/antme-uwp/antme/antme-uwp-web/src/app/app.module.ngfactory.ts]
[/Users/xujin/My_Projects/CSharp/antme-uwp/antme/antme-uwp-web/src/app/app.module.ngfactory.js]
[/Users/xujin/My_Projects/CSharp/antme-uwp/antme/antme-uwp-web/src/app/app.module.ngfactory]
 @ ./src/main.ts 4:0-66
 @ multi webpack-dev-server/client?http://0.0.0.0:0 ./src/main.ts

Dependencies:

"dependencies": {
        "@angular/animations": "^5.1.0",
        "@angular/common": "^5.1.0",
        "@angular/compiler": "^5.1.0",
        "@angular/core": "^5.1.0",
        "@angular/forms": "^5.1.0",
        "@angular/platform-browser": "^5.1.0",
        "@angular/platform-browser-dynamic": "^5.1.0",
        "@angular/router": "^5.1.0",
        "core-js": "^2.4.1",
        "lodash": "^4.17.4",
        "rxjs": "^5.5.2",
        "zone.js": "^0.8.14"
    },
    "devDependencies": {
        "@angular/cli": "^1.6.0",
        "@angular/compiler-cli": "^5.1.0",
        "@angular/language-service": "^5.1.0",
        "@angularclass/hmr": "^2.1.3",
        "@types/jasmine": "~2.5.53",
        "@types/jasminewd2": "~2.0.2",
        "@types/lodash": "^4.14.87",
        "@types/node": "^8.0.31",
        "codelyzer": "^4.0.1",
        "jasmine-core": "~2.6.2",
        "jasmine-spec-reporter": "~4.1.0",
        "karma": "~1.7.0",
        "karma-chrome-launcher": "~2.1.1",
        "karma-cli": "~1.0.1",
        "karma-coverage-istanbul-reporter": "^1.2.1",
        "karma-jasmine": "~1.1.0",
        "karma-jasmine-html-reporter": "^0.2.2",
        "protractor": "~5.1.2",
        "rimraf": "^2.6.1",
        "ts-node": "~3.2.0",
        "tslint": "~5.7.0",
        "typescript": "~2.5.3"
    }

macOS: 10.13.2 Node: 8.9.2 CLI: 1.6.0 Angular: 5.1.0

About this issue

  • Original URL
  • State: closed
  • Created 7 years ago
  • Reactions: 4
  • Comments: 18 (1 by maintainers)

Most upvoted comments

Same here:

ERROR in ./src/main.ts
Module not found: Error: Can't resolve './app/app.module.ngfactory' in '/opt/app/src'
resolve './app/app.module.ngfactory' in '/opt/app/src'
  using description file: /opt/app/package.json (relative path: ./src)
    Field 'browser' doesn't contain a valid alias configuration
  after using description file: /opt/app/package.json (relative path: ./src)
    using description file: /opt/app/package.json (relative path: ./src/app/app.module.ngfactory)
      no extension
        Field 'browser' doesn't contain a valid alias configuration
        /opt/app/src/app/app.module.ngfactory doesn't exist
      .ts
        Field 'browser' doesn't contain a valid alias configuration
        /opt/app/src/app/app.module.ngfactory.ts doesn't exist
      .js
        Field 'browser' doesn't contain a valid alias configuration
        /opt/app/src/app/app.module.ngfactory.js doesn't exist
      as directory
        /opt/app/src/app/app.module.ngfactory doesn't exist
[/opt/app/src/app/app.module.ngfactory]
[/opt/app/src/app/app.module.ngfactory.ts]
[/opt/app/src/app/app.module.ngfactory.js]
[/opt/app/src/app/app.module.ngfactory]
 @ ./src/main.ts 3:0-66
 @ multi webpack-dev-server/client?http://0.0.0.0:0 ./src/main.ts

Ubuntu: 16.04 Node: 7.5.0 CLI: 1.6.0 Angular: 5.0.0