我正在使用动态导入,因此必须像这样更改tsconfig.json
才能将代码定位到esnext
模块。
./src/main/webapp/app/app-routing.module.ts 14:40
Module parse failed: Unexpected token (14:40)
File was processed with these loaders:
* ./node_modules/angular2-template-loader/index.js
* ./node_modules/cache-loader/dist/cjs.js
* ./node_modules/thread-loader/dist/cjs.js
* ./node_modules/ts-loader/index.js
* ./node_modules/angular-router-loader/src/index.js
* ./node_modules/tslint-loader/index.js
You may need an additional loader to handle the result of these loaders.
| {
| path: 'admin',
> loadChildren: () => import('./admin/admin.module').then(m => m.AdminModule),
| },
| ...errorRoute,
tsconfig.json
{
"compilerOptions": {
"target": "es2017",
"module": "esnext",
"moduleResolution": "node",
"sourceMap": true,
"emitDecoratorMetadata": true,
"experimentalDecorators": true,
"removeComments": false,
"noImplicitAny": false,
"skipLibCheck": true,
"suppressImplicitAnyIndexErrors": true,
"outDir": "target/classes/static/app",
"lib": ["es7", "dom"],
"typeRoots": ["node_modules/@types"],
"baseUrl": "./",
"paths": {
"app/*": ["src/main/webapp/app/*"]
},
"importHelpers": true,
"allowJs": true
},
"include": ["src/main/webapp/app", "src/test/javascript/"],
"exclude": ["node_modules"]
}
app-routing.module.ts
import { NgModule } from '@angular/core';
import { RouterModule } from '@angular/router';
import { errorRoute } from './layouts';
import { DEBUG_INFO_ENABLED } from 'app/app.constants';
@NgModule({
imports: [
RouterModule.forRoot(
[
{
path: 'admin',
loadChildren: () => import('./admin/admin.module').then(m => m.AdminModule),
},
...errorRoute,
],
{ enableTracing: DEBUG_INFO_ENABLED }
),
],
exports: [RouterModule],
})
export class AppRoutingModule {}
答案 0 :(得分:0)
那是一个jhipster自己的错误。请检查this issue了解更多详情。
答案 1 :(得分:-1)
rm -rf node_modules
rm -f package-lock.json
npm install