未加载Angular 5 Runtime编译器

时间:2017-12-05 20:47:35

标签: angular angular-cli

我正在使用

编译我的角项目
ng build --prod

但是我得到了

main.bundle.js:1 ERROR Error: Uncaught (in promise): Error: Runtime compiler is not loaded

我无法弄明白该怎么做。 这是我的package.json

{
  "name": "gestionerADJ",
  "version": "0.0.1",
  "license": "MIT",
  "scripts": {
    "ng": "ng",
    "start": "ng serve",
    "build": "ng build",
    "test": "ng test",
    "lint": "ng lint",
    "e2e": "ng e2e"
  },
  "private": true,
  "dependencies": {
    "@angular/animations": "^5.0.0",
    "@angular/common": "^5.0.0",
    "@angular/compiler": "^5.0.0",
    "@angular/core": "^5.0.0",
    "@angular/forms": "^5.0.0",
    "@angular/http": "^5.0.0",
    "@angular/platform-browser": "^5.0.0",
    "@angular/platform-browser-dynamic": "^5.0.0",
    "@angular/router": "^5.0.0",
    "bootstrap": "^4.0.0-beta.2",
    "core-js": "^2.4.1",
    "ngx-bootstrap": "^2.0.0-beta.8",
    "rxjs": "5.5.2",
    "zone.js": "^0.8.14"
  },
  "devDependencies": {
    "@angular/cli": "^1.5.5",
    "@angular/compiler-cli": "^5.0.0",
    "@angular/language-service": "^5.0.0",
    "@types/jasmine": "~2.5.53",
    "@types/jasminewd2": "~2.0.2",
    "@types/node": "~6.0.60",
    "codelyzer": "~3.2.0",
    "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",
    "ts-node": "~3.2.0",
    "tslint": "~5.7.0",
    "typescript": "~2.4.2"
  }
}

我已经看到了一些关于这个错误的其他问题,但是他们都没有帮助我..感谢你们中任何一个会帮助我的人!

2 个答案:

答案 0 :(得分:1)

如果你的项目中有任何模块,你不是懒加载,你可能想切换到延迟加载:

export const routes: Routes = [
    {
        path: '',
        component: myComponent,
        children: [
            {
                path: '',
                loadChildren: myModule
            }
        ]
    }
];

使用loadChildren: myModule替换loadChildren: '../../test.module#myModule',使用适合您项目的路径。

答案 1 :(得分:-1)

您可以在Architect的选项下的angular.json中进行更改。添加像这样的惰性模块:

"lazyModules": [""]