Angular ng build会对延迟加载进行制动

时间:2017-11-14 20:22:16

标签: angular build lazy-loading

我有一个延迟加载配置的应用程序,并且使用ng服务但是当我进行构建然后停止工作并且我没有收到任何错误。

是否有任何进程丢失?我甚至阅读了有棱角的官方文档,似乎没有遗漏任何东西。

我使用角度CLI安装应用程序&new-project-x'。我有最少的图书馆。

这是我的package.json:

{
  "name": "single-boilerplate",
  "version": "0.0.0",
  "license": "MIT",
  "scripts": {
    "ng": "ng",
    "start": "ng serve",
    "build": "ng build",
    "test": "ng test",
    "lint": "ng lint",
    "e2e": "ng e2e"
  },
  "private": true,
  "dependencies": {
    "@angular-redux/store": "^6.5.7",
    "@angular/animations": "^4.2.4",
    "@angular/common": "^4.2.4",
    "@angular/compiler": "^4.2.4",
    "@angular/core": "^4.2.4",
    "@angular/forms": "^4.2.4",
    "@angular/http": "^4.2.4",
    "@angular/platform-browser": "^4.2.4",
    "@angular/platform-browser-dynamic": "^4.2.4",
    "@angular/router": "^4.2.4",
    "@ngx-translate/core": "^8.0.0",
    "@ngx-translate/http-loader": "^2.0.0",
    "core-js": "^2.4.1",
    "font-awesome": "^4.7.0",
    "ng2-validation": "^4.2.0",
    "redux": "^3.7.2",
    "rxjs": "^5.4.2",
    "zone.js": "^0.8.14"
  },
  "devDependencies": {
    "@angular/cli": "^1.5.0",
    "@angular/compiler-cli": "^4.2.4",
    "@angular/language-service": "^4.2.4",
    "@types/es6-shim": "^0.31.35",
    "@types/jasmine": "~2.5.53",
    "@types/jasminewd2": "~2.0.2",
    "@types/node": "^6.0.90",
    "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.3.3"
  }
}

这是我的主要路由器:

export const AppRoutes: Routes = [
  {
    path: '',
    component: AppComponent,
    children: [
      { path: '', loadChildren: './components/dashboard/dashboard.module#DashboardModule' }
    ]
  },
  {
    path: '',
    component: AuthComponent,
    children: [
      { path: '', loadChildren: './components/auth/auth.module#AuthModule' }
    ]
  },
  {
    path: '**',
    redirectTo: '404'
  }
];

我现在不知道是什么问题。发生在你们这些人身上吗?

1 个答案:

答案 0 :(得分:0)

解决方案1 ​​

尝试删除您的package.lock.json(或yarn.lock.json)文件,删除node_modules文件夹,删除package.json文件中对网络包的任何引用(您不要看起来有一个,但你不能只安装两个版本的webpack,只能通过CLI提供一个版本),然后运行npm install

检查是否安装了两个版本的webpack的方法是运行npm ls webpack,但是除非它没有保存到package.json,否则您似乎没有一个版本

我在Github找到了这个解决方案,它对我有用,显然还有其他一些海报。

解决方案2

如果上述情况不起作用,有些人似乎只是更新到4.x的新版本。