Raph
Raph

Reputation: 521

Aot ng build in Angular 4

I have some problem with my compilation aot in angular 4, this is my package.json:

  "dependencies": {
    "@agm/core": "1.0.0-beta.0",
    "@angular/animations": "4.4.6",
    "@angular/common": "4.4.6",
    "@angular/compiler": "4.4.6",
    "@angular/compiler-cli": "4.4.6",
    "@angular/core": "4.4.6",
    "@angular/forms": "4.4.6",
    "@angular/http": "4.4.6",
    "@angular/platform-browser": "4.4.6",
    "@angular/platform-browser-dynamic": "4.4.6",
    "@angular/platform-server": "4.4.6",
    "@angular/router": "4.4.6",
    "@types/iban": "0.0.28",
    "core-js": "2.4.1",
    "dialog-polyfill": "0.4.7",
    "enhanced-resolve": "3.3.0",
    "font-awesome": "4.7.0",
    "iban": "0.0.8",
    "material-design-lite": "1.3.0",
    "modernizr": "3.5.0",
    "moment": "2.18.1",
    "raven-js": "3.12.1",
    "rxjs": "5.0.1",
    "ts-helpers": "1.1.1",
    "typescript": "^2.3.4",
    "web-animations-js": "2.2.2",
    "zone.js": "^0.8.4"
  },

      "devDependencies": {
        "@angular/cli": "^1.4.9",
        "@angular/compiler-cli": "4.4.6",
        "@ngtools/webpack": "1.7.4",
        "@angular/language-service": "4.4.6",
        "@types/core-js": "0.9.35",
        "@types/jasmine": "2.5.38",
        "@types/node": "6.0.42",
        "chai": "3.5.0",
        "chai-as-promised": "6.0.0",
        "chai-colors": "1.0.1",
        "codelyzer": "~2.0.0-beta.1",
        "compodoc": "0.0.32",
        "cucumber": "1.3.3",
        "cucumber-assert": "2.0.0",
        "cucumber-html-report": "0.5.9",
        "cucumber-junit-reporter": "git://github.com/davidparsson/cucumber-junit-reporter.git",
        "cucumberjs-junitxml": "1.0.0",
        "jasmine-core": "2.5.2",
        "jasmine-spec-reporter": "2.5.0",
        "karma": "1.2.0",
        "karma-chrome-launcher": "2.0.0",
        "karma-cli": "1.0.1",
        "karma-firefox-launcher": "1.0.1",
        "karma-jasmine": "1.0.2",
        "karma-phantomjs-launcher": "1.0.4",
        "karma-remap-istanbul": "0.2.1",
        "protractor": "~5.1.2",
        "protractor-cucumber-framework": "3.1.0",
        "ts-node": "1.2.1",
        "tslint": "4.0.2",
        "typescript": "^2.1.5"
      }

When I launch the command "ng build --aot" I had this error:

looking for modules in /Users/raph/app/project/src
            using description file: /Users/raph/app/project/package.json (relative path: ./src)
              Field 'browser' doesn't contain a valid alias configuration
            after using description file: /Users/raph/app/project/package.json (relative path: ./src)
              using description file: /Users/raph/app/project/package.json (relative path: ./src/@angular/router/testing/src/router_testing_module)
                no extension
                  Field 'browser' doesn't contain a valid alias configuration
                  /Users/raph/app/project/src/@angular/router/testing/src/router_testing_module doesn't exist
                .ts
                  Field 'browser' doesn't contain a valid alias configuration
                  /Users/raph/app/project/src/@angular/router/testing/src/router_testing_module.ts doesn't exist
                .js
                  Field 'browser' doesn't contain a valid alias configuration
                  /Users/raph/app/project/src/@angular/router/testing/src/router_testing_module.js doesn't exist
                as directory
                  /Users/raph/app/project/src/@angular/router/testing/src/router_testing_module doesn't exist
    [/Users/raph/app/project/src/$$_gendir/app/core-module/node_modules]
    [/Users/raph/app/project/src/$$_gendir/app/node_modules]
    [/Users/raph/app/project/src/node_modules]
    [/Users/raph/app/node_modules]
    [/Users/raph/node_modules]
    [/Users/node_modules]
    [/node_modules]
    [/Users/raph/app/project/node_modules/@angular/router/testing/src/router_testing_module]
    [/Users/raph/app/project/node_modules/@angular/router/testing/src/router_testing_module.ts]
    [/Users/raph/app/project/node_modules/@angular/router/testing/src/router_testing_module.js]
    [/Users/raph/app/webapp/node_modules/@angular/router/testing/src/router_testing_module]

Maybe this is a problem with my configuration in my package.json or an include in my file , I can't find something when I try to debug.

This error is only present when I build with AOT mode.

Upvotes: 0

Views: 625

Answers (1)

Igor
Igor

Reputation: 62213

Looks like you are possibly packaging up your unit test(s) too with your aot build. The reason I say this is because I see router_testing_module referenced in your stack trace. That leads me to believe you are either:

  • Including your spec (test) files by not excluding them all in your tsconfig.json file.
  • Referencing spec (test) files from your production code / modules

Upvotes: 1

Related Questions