jhipster / generator-jhipster

JHipster is a development platform to quickly generate, develop, & deploy modern web applications & microservice architectures.
https://www.jhipster.tech
Apache License 2.0
21.54k stars 4.02k forks source link

Application build fails with webpack error #23743

Closed ozewski closed 1 year ago

ozewski commented 1 year ago
Overview of the issue

When trying to build the application using npm start, the webpack serve command throws a cryptic error. My application's file structure has been modified, but solely within the src/main/webapp/app folder. All other paths have remained unchanged so far.

Motivation for or Use Case

This error interferes with building the app.

Reproduce the error

I cannot find the specific cause of this error or how to reproduce. Here is the result of running npm start:


C:\Users\*****\projects\******>npm start

> sdrui@0.0.1-SNAPSHOT start
> npm run webapp:dev --

> sdrui@0.0.1-SNAPSHOT webapp:dev
> npm run webpack-dev-server -- --config webpack/webpack.dev.js --env stats=minimal

> sdrui@0.0.1-SNAPSHOT webpack-dev-server
> webpack serve --config webpack/webpack.dev.js --env stats=minimal

<i> [webpack-dev-server] [HPM] Proxy created: /api,/services,/management,/v3/api-docs,/h2-console,/auth  -> http://localhost:8080
Webpack: Starting ...

  √ Compile modules
  > Build modules (0%)
<i> [webpack-dev-server] Project is running at:
Webpack: Starting ...

  √ Compile modules
  √ Build modules
  √ Optimize modules
  √ Emit files

Finished after 1.946 seconds.

<e> [webpack-dev-middleware] HookWebpackError: Reduce of empty array with no initial value
<e>     at makeWebpackError (C:\Users\molta\projects\sdr-ui-jhipster\node_modules\webpack\lib\HookWebpackError.js:48:9)
<e>     at C:\Users\molta\projects\sdr-ui-jhipster\node_modules\webpack\lib\Compilation.js:3060:12
<e>     at eval (eval at create (C:\Users\molta\projects\sdr-ui-jhipster\node_modules\tapable\lib\HookCodeFactory.js:33:10), <anonymous>:87:1)
<e>     at fn (C:\Users\molta\projects\sdr-ui-jhipster\node_modules\webpack\lib\Compilation.js:480:17)
<e>     at _next0 (eval at create (C:\Users\molta\projects\sdr-ui-jhipster\node_modules\tapable\lib\HookCodeFactory.js:33:10), <anonymous>:84:1)
<e>     at eval (eval at create (C:\Users\molta\projects\sdr-ui-jhipster\node_modules\tapable\lib\HookCodeFactory.js:33:10), <anonymous>:101:1)
<e>     at eval (eval at create (C:\Users\molta\projects\sdr-ui-jhipster\node_modules\tapable\lib\HookCodeFactory.js:33:10), <anonymous>:11:1)
<e>     at C:\Users\molta\projects\sdr-ui-jhipster\node_modules\webpack\lib\Compilation.js:502:10
<e>     at Hook.eval [as callAsync] (eval at create (C:\Users\molta\projects\sdr-ui-jhipster\node_modules\tapable\lib\HookCodeFactory.js:33:10), <anonymous>:7:1)
<e>     at Hook.CALL_ASYNC_DELEGATE [as _callAsync] (C:\Users\molta\projects\sdr-ui-jhipster\node_modules\tapable\lib\Hook.js:18:14)
<e> -- inner error --
<e> TypeError: Reduce of empty array with no initial value
<e>     at Array.reduce (<anonymous>)
<e>     at MergeJsonWebpackPlugin.processFiles (C:\Users\molta\projects\sdr-ui-jhipster\node_modules\merge-jsons-webpack-plugin\index.js:20:18)
<e>     at C:\Users\molta\projects\sdr-ui-jhipster\node_modules\merge-jsons-webpack-plugin\index.js:109:26
<e>     at C:\Users\molta\projects\sdr-ui-jhipster\node_modules\webpack\lib\Compilation.js:586:56
<e>     at fn (C:\Users\molta\projects\sdr-ui-jhipster\node_modules\webpack\lib\Compilation.js:478:10)
<e>     at _next0 (eval at create (C:\Users\molta\projects\sdr-ui-jhipster\node_modules\tapable\lib\HookCodeFactory.js:33:10), <anonymous>:84:1)
<e>     at eval (eval at create (C:\Users\molta\projects\sdr-ui-jhipster\node_modules\tapable\lib\HookCodeFactory.js:33:10), <anonymous>:101:1)
<e>     at eval (eval at create (C:\Users\molta\projects\sdr-ui-jhipster\node_modules\tapable\lib\HookCodeFactory.js:33:10), <anonymous>:11:1)
<e>     at C:\Users\molta\projects\sdr-ui-jhipster\node_modules\webpack\lib\Compilation.js:502:10
<e>     at Hook.eval [as callAsync] (eval at create (C:\Users\molta\projects\sdr-ui-jhipster\node_modules\tapable\lib\HookCodeFactory.js:33:10), <anonymous>:7:1)
<e> caused by plugins in Compilation.hooks.processAssets
<e> TypeError: Reduce of empty array with no initial value
<e>     at Array.reduce (<anonymous>)
<e>     at MergeJsonWebpackPlugin.processFiles (C:\Users\molta\projects\sdr-ui-jhipster\node_modules\merge-jsons-webpack-plugin\index.js:20:18)
<e>     at C:\Users\molta\projects\sdr-ui-jhipster\node_modules\merge-jsons-webpack-plugin\index.js:109:26
<e>     at C:\Users\molta\projects\sdr-ui-jhipster\node_modules\webpack\lib\Compilation.js:586:56
<e>     at fn (C:\Users\molta\projects\sdr-ui-jhipster\node_modules\webpack\lib\Compilation.js:478:10)
<e>     at _next0 (eval at create (C:\Users\molta\projects\sdr-ui-jhipster\node_modules\tapable\lib\HookCodeFactory.js:33:10), <anonymous>:84:1)
<e>     at eval (eval at create (C:\Users\molta\projects\sdr-ui-jhipster\node_modules\tapable\lib\HookCodeFactory.js:33:10), <anonymous>:101:1)
<e>     at eval (eval at create (C:\Users\molta\projects\sdr-ui-jhipster\node_modules\tapable\lib\HookCodeFactory.js:33:10), <anonymous>:11:1)
<e>     at C:\Users\molta\projects\sdr-ui-jhipster\node_modules\webpack\lib\Compilation.js:502:10
<e>     at Hook.eval [as callAsync] (eval at create (C:\Users\molta\projects\sdr-ui-jhipster\node_modules\tapable\lib\HookCodeFactory.js:33:10), <anonymous>:7:1)
Related issues

I cannot find a related issue in this repo, nor the webpack repo or the repo for the specific package in use.

Suggest a Fix

I believe this issue is with the merge-json-webpack-plugin package.

JHipster configuration
JHipster Version(s)
sdrui@0.0.1-SNAPSHOT C:\Users\****\projects\*****
`-- generator-jhipster@7.9.4
JHipster configuration, a .yo-rc.json file generated in the root folder
.yo-rc.json file
{
  "generator-jhipster": {
    "applicationType": "monolith",
    "authenticationType": "jwt",
    "baseName": "sdrui",
    "blueprints": [],
    "buildTool": "maven",
    "cacheProvider": "ehcache",
    "clientFramework": "react",
    "clientPackageManager": "npm",
    "clientTheme": "none",
    "clientThemeVariant": "",
    "creationTimestamp": 1696265821418,
    "cypressAudit": false,
    "cypressCoverage": null,
    "databaseType": "sql",
    "devDatabaseType": "h2Disk",
    "devServerPort": 9060,
    "dtoSuffix": "DTO",
    "enableGradleEnterprise": false,
    "enableHibernateCache": true,
    "enableSwaggerCodegen": false,
    "enableTranslation": true,
    "entitySuffix": "",
    "jhiPrefix": "jhi",
    "jhipsterVersion": "7.9.4",
    "jwtSecretKey": "YourJWTSecretKeyWasReplacedByThisMeaninglessTextByTheJHipsterInfoCommandForObviousSecurityReasons",
    "languages": ["en"],
    "messageBroker": false,
    "microfrontend": false,
    "microfrontends": [],
    "nativeLanguage": "en",
    "otherModules": [],
    "packageName": "com.lufco.sdrui",
    "pages": [],
    "prodDatabaseType": "postgresql",
    "reactive": false,
    "searchEngine": false,
    "serverPort": "8080",
    "serverSideOptions": [],
    "serviceDiscoveryType": "eureka",
    "skipCheckLengthOfIdentifier": false,
    "skipClient": false,
    "skipFakeData": false,
    "skipUserManagement": false,
    "testFrameworks": ["cypress"],
    "websocket": false,
    "withAdminUi": true
  }
}

JDL for the Entity configuration(s) entityName.json files generated in the .jhipster directory
JDL entity definitions

Environment and Tools

java version "17.0.8" 2023-07-18 LTS Java(TM) SE Runtime Environment (build 17.0.8+9-LTS-211) Java HotSpot(TM) 64-Bit Server VM (build 17.0.8+9-LTS-211, mixed mode, sharing)

git version 2.42.0.windows.2

node: v18.17.1

npm: 9.6.7

Docker version 24.0.6, build ed223bc

Docker Compose version v2.22.0-desktop.2

Entity configuration(s) entityName.json files generated in the .jhipster directory

No entities being used.

Browsers and Operating System

Windows (browser irrelevant)

github-actions[bot] commented 1 year ago

JHipster has completed the sample check .yo-rc.json: valid Entities JDL: blank Application: successfully generated Frontend check: success Backend check: success E2E check: success

mshima commented 1 year ago

Check your translations folder it may be missing. And check if the translation path is correct at webpack config. Closing since CI is passing with provided sample.