我如何永久摆脱:webpackAsyncContext(位于./src/$$_lazy_route_resource的laval递归

时间:2018-12-10 20:29:09

标签: angular5 angular-cli lazy-loading

我实际上是在尝试不吹垫圈,但是这个错误使我发疯。

所以,历史:在本地项目和全局安装中,我都必须使用ng-cli 1.7.4从ng7降级到ng5。

我遇到的问题是,该项目是设计为延迟加载的,并且我已经完成了在该SO答案中找到的匹配建议:Suggest to match global and local Angular-Cli's

我的代码正在将其用于app-routing.module.ts:

import {NgModule} from '@angular/core';
import {Routes, RouterModule} from '@angular/router';

import {DocumentWorkbenchComponent} from './shared/components/document-workbench/document-workbench.component';
import {SelectivePreloadingStrategy} from './core/preloading-strategy/selective.preloading-strategy';
import {MyComponent} from './my/my.component';

const routes: Routes = [
  {
    path: 'dashboard',
    loadChildren: 'app/dashboard/dashboard.module#DashboardModule'
  },
  {
    path: 'DocumentWorkbench/:user/:number/:portalCaseID/:caseID/:reviewDocumentID/:token/:modeView/:dmsId',
    component: DocumentWorkbenchComponent
  },
  {
    path: 'application',
    loadChildren: 'app/applications/applications.module#ApplicationsModule'
  },
  {
    path: 'accounts',
    loadChildren: 'app/accounts/accounts.module#AccountsModule'
  },
  {
    path: 'search',
    loadChildren: 'app/search/search.module#SearchModule'
  },
  {
    path: 'watchlist',
    loadChildren: 'app/watchlist/watchlist.module#WatchlistModule'
  },
  {
    path: 'admin',
    loadChildren: 'app/admin/admin.module#AdminModule'
  },
  {
    path: 'my',
    loadChildren: 'app/my/my-routes/my.module#MyModule'
  },
  {
    path: 'message',
    loadChildren: 'app/message/message.module#MessageModule'
  },
  {
    path: '',
    pathMatch: 'full',
    redirectTo: 'dashboard'
  }
];

@NgModule({
  imports: [
    RouterModule.forRoot(
      routes,
      {
        useHash: true,
        preloadingStrategy: SelectivePreloadingStrategy
      }
    )
  ],
  exports: [
    RouterModule
  ],
  providers: [
    SelectivePreloadingStrategy
  ]
})

export class AppRoutingModule {
}

我还尝试过简单导入仪表板组件,并使用

正常调用它。
path: 'dashboard',
component: DashboardComponent

这又引入了一系列错误...

信息中心不只加载导航栏。当我单击导航栏中的DASHBOARD时,会生成错误。我真的需要在后台轻松加载简单的bootrap 4模板吗?

我们正在使用Angular 5,Angular-Cli 1.7.4本地和全局,npm 6.4.1,当我执行ng -v时,结果如下:

Angular CLI: 1.7.4
Node: 8.11.1
OS: win32 x64
Angular: 5.2.11
... animations, common, compiler, compiler-cli, core, forms
... http, platform-browser, platform-browser-dynamic
... platform-server, router

@angular/cdk: 5.2.4
@angular/cli: 1.7.4
@angular/language-service: 4.4.7
@angular/material: 5.2.5
@angular-devkit/build-optimizer: 0.3.2
@angular-devkit/core: 0.3.2
@angular-devkit/schematics: 0.3.2
@ngtools/json-schema: 1.2.0
@ngtools/webpack: 1.10.2
@schematics/angular: 0.3.2
@schematics/package-update: 0.3.2
typescript: 2.4.2
webpack: 3.11.0

由于ngx-bootstrap和nlcst-pattern-match和nlcst-parse-english npm模块,我们只能使用上述版本,并且不能降级到cli 1.6.8。

我需要临时解决此问题...

这是错误

ngx-logger.js:247 2018-12-10T18:41:41.754Z ERROR [errors- 
handler.service.ts:19] Error: Uncaught (in promise): 
TypeError: undefined is not a function
TypeError: undefined is not a function
at Array.map (<anonymous>)
at webpackAsyncContext (eval at ./src/$$_lazy_route_resource lazy recursive (http://localhost:4200/main.bundle.js:20:1), <anonymous>:101:34)

这是偶发性的,仅当我npm删除并重新安装angular-cli时才起作用。这真是神经病。

更新:我发现,当我转储package-lock.json并进行npm安装时,一切正常。

无论是否重新启动机器,我都无法在生产环境中继续这样做。

0 个答案:

没有答案