简体   繁体   中英

Routing error in lazy loading after upgrading to Angular 8

I have upgraded to Angular 8 and found the in lazy loading modules routing. While upgrading CLI itself changed all my lazy loading routes according to new syntax.

ERROR in ./src/app/app.routing.ts 31:36 Module parse failed: Unexpected token (31:36) You may need an appropriate loader to handle this file type. | title: "abc" | },

 loadChildren: () => import('./modules/abc/abc.module').then(m => m.AbcModule)

| }, | {

children: [ {path: '', pathMatch: 'full', component: InfoComponent, canActivate: [AuthGuard], }, { path: 'abc', loadChildren: () => import('abc/abc.module').then((m) => m.AbcModule), }]

You could try to remove the package-lock.json and run npm install again. If this does not work, you could try to run yarn . This will fix the acorn package from webpack. You can also try this manually by updating to acorn@6.1.1 using npm.

https://github.com/angular/angular-cli/issues/14566

Install acorn node module to existing project.

npm install acorn@6.1.0--save

Then try below instruction,This might solve the problem.

  1. rm -rf node_modules
  2. rm -f package-lock.json
  3. npm install

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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