简体   繁体   English

在Angular 4中构建

[英]Aot ng build in Angular 4

I have some problem with my compilation aot in angular 4, this is my package.json: 我在angular 4中的编译aot有一些问题,这是我的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: 当我启动命令“ 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]

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. 也许这是我的package.json中的配置问题或文件中的include的问题,当我尝试调试时找不到任何东西。

This error is only present when I build with AOT mode. 仅当我使用AOT模式构建时才会出现此错误。

Looks like you are possibly packaging up your unit test(s) too with your aot build. 看起来您也可能会与aot构建一起打包单元测试。 The reason I say this is because I see router_testing_module referenced in your stack trace. 我之所以这么说是因为我在您的堆栈跟踪中看到了router_testing_module That leads me to believe you are either: 这使我相信您是:

  • Including your spec (test) files by not excluding them all in your tsconfig.json file. 通过不排除tsconfig.json文件中的所有内容来包含您的spec (测试)文件。
  • Referencing spec (test) files from your production code / modules 从生产代码/模块中引用spec (测试)文件

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM