'Jhipster jenkins: ERROR in NaNbut they point to different modules Webpack cannot distinguish on context and would fail to load

I am trying to build a Jhipster project in Jenkins. The project runs fine in my local. However, it is throwing the below error in Jenkins run during 'yarn nun webpack:build'. Below is the error:

ERROR in NaNbut they point to different modules "(<jenkins wrokspace>/mybuild/target/myapp-snapshot-0.0.1.jar/app/admin//admin.module.ts and "<jenkins wrokspace>/mybuild/src/main/webapp/app/admin/admin.module.ts"). Webpack cannot distinguish on context and would fail to load the proper one.

adding the app-routing-mdule.ts

import { NgModule } from '@angular/core';
import { RouterModule } from '@angular/router';
import { errorRoute } from './layouts/error/error.route';
import { navbarRoute } from './layouts/navbar/navbar.route';

const LAYOUT_ROUTES = [navbarRoute, ...errorRoute];

@NgModule({
  imports: [
    RouterModule.forRoot(
      [
        {
          path: 'admin',
          loadChildren: './admin/admin.module#AdminUIModule,
        },
        
        ...LAYOUT_ROUTES,
      ],
      { enableTracing: DEBUG_INFO_ENABLED }
    ),
  ],
  exports: [RouterModule],
})
export class RmrsAppRoutingModule {}

Please help me out. Let me know what else details need to be posted here.



Solution 1:[1]

Delete the target folder from the project and run the command again.

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 David López