Сборка Aot ng в Angular 4

У меня есть проблема с моей компиляцией в angular 4, это мой 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"
      }

Когда я запускаю команду «ng build --aot», у меня была эта ошибка:

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]

Возможно, это проблема с моей конфигурацией в моем package.json или включением в мой файл, я не могу найти что-то при попытке отладки.

Эта ошибка присутствует только при сборке в режиме AOT.


person Raph    schedule 30.10.2017    source источник
comment
Похоже, вы, возможно, также упаковываете свои модульные тесты с помощью файла tsconfig.json вашего aot. Вы забыли исключить файлы .spec.ts?   -  person Igor    schedule 30.10.2017
comment
Да, у меня есть раздел исключения в моем tsconfig.app.json.   -  person Raph    schedule 31.10.2017
comment
Причина, по которой я спрашиваю, заключается в том, что я вижу ссылку на router_testing_module в вашей трассировке стека. Это наводит меня на мысль, что вы либо включаете свои spec (тестовые) файлы ИЛИ у вас есть ссылки на ваши spec (тестовые) файлы из вашего производственного кода.   -  person Igor    schedule 31.10.2017
comment
Большое спасибо, вы поставили меня на хороший путь. У меня был импорт в файл спецификации в моем CoreModule: import {RouterTestingModule} from '@angular/router/testing';   -  person Raph    schedule 31.10.2017
comment
Это сработает. Я собираюсь поставить это как ответ на данный момент ...   -  person Igor    schedule 31.10.2017


Ответы (1)


Похоже, вы, возможно, также упаковываете свои модульные тесты в свою сборку aot. Причина, по которой я говорю это, заключается в том, что я вижу ссылку на router_testing_module в вашей трассировке стека. Это заставляет меня поверить, что вы либо:

  • Включение ваших spec (тестовых) файлов, не исключая их всех из вашего tsconfig.json файла.
  • Ссылки на spec (тестовые) файлы из вашего производственного кода/модулей
person Igor    schedule 30.10.2017