Generator-jhipster: Generating a Angular Monolith throws Cannot read property 'forEach' of undefined error

Created on 14 Oct 2019  Â·  12Comments  Â·  Source: jhipster/generator-jhipster

Overview of the issue

I've tried to create a new angular monolith with an sql server backend using the following configuration:

{
"generator-jhipster": {
"promptValues": {
"packageName": "com.xxx.yyy"
},
"jhipsterVersion": "6.4.0",
"applicationType": "monolith",
"baseName": "xxx",
"packageName": "com.xxx.yyy",
"packageFolder": "com/xxx/yyy",
"serverPort": "8080",
"authenticationType": "jwt",
"cacheProvider": "ehcache",
"enableHibernateCache": true,
"websocket": false,
"databaseType": "sql",
"devDatabaseType": "mssql",
"prodDatabaseType": "mssql",
"searchEngine": false,
"messageBroker": false,
"serviceDiscoveryType": "eureka",
"buildTool": "maven",
"enableSwaggerCodegen": false,
"jwtSecretKey": "",
"embeddableLaunchScript": false,
"useSass": true,
"clientPackageManager": "npm",
"clientFramework": "angularX",
"clientTheme": "sandstone",
"clientThemeVariant": "primary",
"testFrameworks": [
"gatling",
"cucumber",
"protractor"
],
"jhiPrefix": "jhi",
"entitySuffix": "",
"dtoSuffix": "DTO",
"otherModules": [],
"enableTranslation": false,
"blueprints": []
}
}

Once the build reaches the angular phase, an exception is thrown:

[INFO] Webpack: Starting ...
[INFO] Starting type checking service...
Webpack: Starting ...
[INFO]
[INFO] ✔ Compile modules
[INFO] ✔ Build modules
[INFO] ✔ Optimize modules
[INFO] ✔ Emit files
[INFO]
[INFO] Webpack: Finished after 22.889 seconds.
[INFO]
[INFO] ERROR Failed to compile with 2 errors4:16:20 PM
[INFO]
[INFO] Module build failed (from ./node_modules/thread-loader/dist/cjs.js):
[INFO] Thread Loader (Worker 0)
[INFO] Cannot read property 'forEach' of undefined
[INFO] at PoolWorker.fromErrorObj (/Users/frayala/Documents/source/xxx/node_modules/thread-loader/dist/WorkerPool.js:262:12)
[INFO] at /Users/frayala/Documents/source/xxx/node_modules/thread-loader/dist/WorkerPool.js:204:29
[INFO] at mapSeries (/Users/frayala/Documents/source/xxx/node_modules/neo-async/async.js:3625:14)
[INFO] at Linter.parseResults (/Users/frayala/Documents/source/xxx/node_modules/eslint-loader/dist/Linter.js:121:13)
[INFO] at Linter.printOutput (/Users/frayala/Documents/source/xxx/node_modules/eslint-loader/dist/Linter.js:85:26)
[INFO] at Object.loader (/Users/frayala/Documents/source/xxx/node_modules/eslint-loader/dist/index.js:26:10)
[INFO]
[INFO] Module build failed (from ./node_modules/thread-loader/dist/cjs.js):
[INFO] Thread Loader (Worker 1)
[INFO] Cannot read property 'forEach' of undefined
[INFO] at PoolWorker.fromErrorObj (/Users/frayala/Documents/source/xxx/node_modules/thread-loader/dist/WorkerPool.js:262:12)
[INFO] at /Users/frayala/Documents/source/xxx/node_modules/thread-loader/dist/WorkerPool.js:204:29
[INFO] at mapSeries (/Users/frayala/Documents/source/xxx/node_modules/neo-async/async.js:3625:14)
[INFO] at Linter.parseResults (/Users/frayala/Documents/source/xxx/node_modules/eslint-loader/dist/Linter.js:121:13)
[INFO] at Linter.printOutput (/Users/frayala/Documents/source/xxx/node_modules/eslint-loader/dist/Linter.js:85:26)
[INFO] at Object.loader (/Users/frayala/Documents/source/xxx/node_modules/eslint-loader/dist/index.js:26:10)
[INFO]
[INFO] You may use special comments to disable some warnings.
[INFO] Use // eslint-disable-next-line to ignore the next line.
[INFO] Use /* eslint-disable */ to ignore all warnings in a file.
[INFO] 6 modules
[INFO]
[INFO] WARNING in ./src/main/webapp/app/polyfills.ts
[INFO] Module Warning (from ./node_modules/thread-loader/dist/cjs.js):
[INFO] Failed to load config "jhipster" to extend from.
[INFO] Referenced from: /Users/frayala/Documents/source/.eslintrc.json
[INFO]
[INFO] WARNING in ./src/main/webapp/app/app.main.ts
[INFO] Module Warning (from ./node_modules/thread-loader/dist/cjs.js):
[INFO] Failed to load config "jhipster" to extend from.
[INFO] Referenced from: /Users/frayala/Documents/source/.eslintrc.json
[INFO]
[INFO] ERROR in ./src/main/webapp/app/polyfills.ts
[INFO] Module build failed (from ./node_modules/thread-loader/dist/cjs.js):
[INFO] Thread Loader (Worker 0)
[INFO] Cannot read property 'forEach' of undefined
[INFO] at PoolWorker.fromErrorObj (/Users/frayala/Documents/source/xxx/node_modules/thread-loader/dist/WorkerPool.js:262:12)
[INFO] at /Users/frayala/Documents/source/xxx/node_modules/thread-loader/dist/WorkerPool.js:204:29
[INFO] at mapSeries (/Users/frayala/Documents/source/xxx/node_modules/neo-async/async.js:3625:14)
[INFO] at Linter.parseResults (/Users/frayala/Documents/source/xxx/node_modules/eslint-loader/dist/Linter.js:121:13)
[INFO] at Linter.printOutput (/Users/frayala/Documents/source/xxx/node_modules/eslint-loader/dist/Linter.js:85:26)
[INFO] at Object.loader (/Users/frayala/Documents/source/xxx/node_modules/eslint-loader/dist/index.js:26:10)
[INFO]
[INFO] ERROR in ./src/main/webapp/app/app.main.ts
[INFO] Module build failed (from ./node_modules/thread-loader/dist/cjs.js):
[INFO] Thread Loader (Worker 1)
[INFO] Cannot read property 'forEach' of undefined
[INFO] at PoolWorker.fromErrorObj (/Users/frayala/Documents/source/xxx/node_modules/thread-loader/dist/WorkerPool.js:262:12)
[INFO] at /Users/frayala/Documents/source/xxx/node_modules/thread-loader/dist/WorkerPool.js:204:29
[INFO] at mapSeries (/Users/frayala/Documents/source/xxx/node_modules/neo-async/async.js:3625:14)
[INFO] at Linter.parseResults (/Users/frayala/Documents/source/xxx/node_modules/eslint-loader/dist/Linter.js:121:13)
[INFO] at Linter.printOutput (/Users/frayala/Documents/source/xxx/node_modules/eslint-loader/dist/Linter.js:85:26)
[INFO] at Object.loader (/Users/frayala/Documents/source/xxx/node_modules/eslint-loader/dist/index.js:26:10)
[INFO] npm ERR! code ELIFECYCLE
[INFO] npm ERR! errno 2
[INFO] npm ERR! [email protected] webpack: node --max_old_space_size=4096 node_modules/webpack/bin/webpack.js "--config" "webpack/webpack.dev.js" "--env.stats=minimal"
[INFO] npm ERR! Exit status 2
[INFO] npm ERR!
[INFO] npm ERR! Failed at the [email protected] webpack script.
[INFO] npm ERR! This is probably not a problem with npm. There is likely additional logging output above.
[INFO]
[INFO] npm ERR! A complete log of this run can be found in:
[INFO] npm ERR! /Users/frayala/.npm/_logs/2019-10-14T14_16_20_576Z-debug.log
[INFO] npm ERR! code ELIFECYCLE
[INFO] npm ERR! errno 2
[INFO] npm ERR! [email protected] webpack:build:main: npm run webpack -- --config webpack/webpack.dev.js --env.stats=minimal
[INFO] npm ERR! Exit status 2
[INFO] npm ERR!
[INFO] npm ERR! Failed at the [email protected] webpack:build:main script.
[INFO] npm ERR! This is probably not a problem with npm. There is likely additional logging output above.
[INFO]
[INFO] npm ERR! A complete log of this run can be found in:
[INFO] npm ERR! /Users/frayala/.npm/_logs/2019-10-14T14_16_20_720Z-debug.log
[INFO] npm ERR! code ELIFECYCLE
[INFO] npm ERR! errno 2
[INFO] npm ERR! [email protected] webpack:build: npm run cleanup && npm run webpack:build:main
[INFO] npm ERR! Exit status 2
[INFO] npm ERR!
[INFO] npm ERR! Failed at the [email protected] webpack:build script.
[INFO] npm ERR! This is probably not a problem with npm. There is likely additional logging output above.
[INFO]
[INFO] npm ERR! A complete log of this run can be found in:
[INFO] npm ERR! /Users/frayala/.npm/_logs/2019-10-14T14_16_20_806Z-debug.log
[INFO] ------------------------------------------------------------------------
[INFO] BUILD FAILURE
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 01:14 min
[INFO] Finished at: 2019-10-14T16:16:20+02:00
[INFO] ------------------------------------------------------------------------
[ERROR] Failed to execute goal com.github.eirslett:frontend-maven-plugin:1.8.0:npm (webpack build dev) on project xxx: Failed to run task: 'npm run webpack:build' failed. org.apache.commons.exec.ExecuteException: Process exited with an error: 2 (Exit value: 2) -> [Help 1]
[ERROR]
[ERROR] To see the full stack trace of the errors, re-run Maven with the -e switch.
[ERROR] Re-run Maven using the -X switch to enable full debug logging.
[ERROR]
[ERROR] For more information about the errors and possible solutions, please read the following articles:
[ERROR] [Help 1] http://cwiki.apache.org/confluence/display/MAVEN/MojoFailureException

Motivation for or Use Case

Cannot run JHipster application.

Reproduce the error

Create new monolithic application on Mac, then run it using ./mvnw

JHipster Version(s)

JHipster v6.4.0

JHipster configuration, a .yo-rc.json file generated in the root folder


.yo-rc.json file

{
  "generator-jhipster": {
    "promptValues": {
      "packageName": "com.xxx.yyy"
    },
    "jhipsterVersion": "6.4.0",
    "applicationType": "monolith",
    "baseName": "xxx",
    "packageName": "com.xxx.yyy",
    "packageFolder": "com/xxx/relpreintegconsult",
    "serverPort": "8080",
    "authenticationType": "jwt",
    "cacheProvider": "ehcache",
    "enableHibernateCache": true,
    "websocket": false,
    "databaseType": "sql",
    "devDatabaseType": "mssql",
    "prodDatabaseType": "mssql",
    "searchEngine": false,
    "messageBroker": false,
    "serviceDiscoveryType": "eureka",
    "buildTool": "maven",
    "enableSwaggerCodegen": false,
    "jwtSecretKey": "",
    "embeddableLaunchScript": false,
    "useSass": true,
    "clientPackageManager": "npm",
    "clientFramework": "angularX",
    "clientTheme": "sandstone",
    "clientThemeVariant": "primary",
    "testFrameworks": [
      "gatling",
      "cucumber",
      "protractor"
    ],
    "jhiPrefix": "jhi",
    "entitySuffix": "",
    "dtoSuffix": "DTO",
    "otherModules": [],
    "enableTranslation": false,
    "blueprints": []
  }
}

Browsers and Operating System

MacOS Mojave
Chrome 77

Environment and Tools

java version "1.8.0_131"
Java(TM) SE Runtime Environment (build 1.8.0_131-b11)
Java HotSpot(TM) 64-Bit Server VM (build 25.131-b11, mixed mode)

git version 2.21.0 (Apple Git-122)

node: v8.11.3

npm: 6.9.0

yarn: 1.9.4

Docker version 18.09.2, build 6247962

docker-compose version 1.23.2, build 1110ad01

  • [ x] Checking this box is mandatory (this is just to show you read everything)
needs-reproduction waiting for information

Most helpful comment

@Lina-Hammami Failure is about eslint, so I suppose it also fails when you run npm run lint? As a temporary workaround and to confirm there's an issue with eslint could you comment out the eslint-loader rule configuration in webpack/webpack.dev.js like below?

~js
module: {
rules: [ /* {
test: /.(j|t)s$/,
enforce: 'pre',
loader: 'eslint-loader',
exclude: /node_modules/
}, */
~

All 12 comments

Hi !

I just tried your configuration @FreddyAyala but didn't manage to reproduce with a freshly created app. Here is a repo with the freshly created app which seems working: https://github.com/clement26695/10619.

Did you modify something in the generated code or updated from a previous version of JHipster ? Can you provide a git repository that we can check ?

@FreddyAyala : can you try to use Node LTS too ?

Closing this as it couldn't be reproduced.
Feel free to comment or provide more information, once you tried with Node LTS

I had this happen after an upgrade to 6.4.1 with an LTS node 10.16.3

running npm run webpack:build resulted in the same error/stack (Cannot read property 'forEach' of undefined)

I ran npm lint and got an error about "extends" in tslint.json (which was a botched merge).

Subsequently the error disappeared and I cannot reproduce it even with the "extends" so it leads me to believe something was cached. I'm not familiar with eslint's cache (if used) but that might be the issue.

same issue here with node v12.13.1 LTS

@GregorHue can you paste the error you get and the output of jhipster info ?

I still have the same problem as the error after executing npm run webpack:build:main is :

` ERROR Failed to compile with 2 errors 1:33:28 AM

Module build failed (from ./node_modules/thread-loader/dist/cjs.js):
Thread Loader (Worker 0)
Cannot read property 'forEach' of undefined
at PoolWorker.fromErrorObj (/home/lina/PCD/app/node_modules/thread-loader/dist/WorkerPool.js:262:12)
at /home/lina/PCD/app/node_modules/thread-loader/dist/WorkerPool.js:204:29
at mapSeries (/home/lina/PCD/app/node_modules/neo-async/async.js:3625:14)
at PoolWorker.onWorkerMessage (/home/lina/PCD/app/node_modules/thread-loader/dist/WorkerPool.js:170:35)
at Linter.parseResults (/home/lina/PCD/app/node_modules/eslint-loader/dist/Linter.js:121:13)
at Linter.printOutput (/home/lina/PCD/app/node_modules/eslint-loader/dist/Linter.js:85:26)
at Object.loader (/home/lina/PCD/app/node_modules/eslint-loader/dist/index.js:26:10)

Module build failed (from ./node_modules/thread-loader/dist/cjs.js):
Thread Loader (Worker 1)
Cannot read property 'forEach' of undefined
at PoolWorker.fromErrorObj (/home/lina/PCD/app/node_modules/thread-loader/dist/WorkerPool.js:262:12)
at /home/lina/PCD/app/node_modules/thread-loader/dist/WorkerPool.js:204:29
at mapSeries (/home/lina/PCD/app/node_modules/neo-async/async.js:3625:14)
at PoolWorker.onWorkerMessage (/home/lina/PCD/app/node_modules/thread-loader/dist/WorkerPool.js:170:35)
at Linter.parseResults (/home/lina/PCD/app/node_modules/eslint-loader/dist/Linter.js:121:13)
at Linter.printOutput (/home/lina/PCD/app/node_modules/eslint-loader/dist/Linter.js:85:26)
at Object.loader (/home/lina/PCD/app/node_modules/eslint-loader/dist/index.js:26:10)
`

and the output of jhipster info is

`INFO! Using JHipster version installed locally in current project's node_modules
INFO! Executing jhipster:info
INFO! Options: from-cli: true
Welcome to the JHipster Information Sub-Generator

JHipster Version(s)
[email protected] /home/lina/PCD/app
└── [email protected] 

##### **JHipster configuration, a `.yo-rc.json` file generated in the root folder**
.yo-rc.json file
{
  "generator-jhipster": {
    "databaseType": "sql",
    "devDatabaseType": "h2Disk",
    "enableHibernateCache": true,
    "enableSwaggerCodegen": false,
    "enableTranslation": true,
    "jhiPrefix": "jhi",
    "languages": [
      "en",
      "fr"
    ],
    "messageBroker": false,
    "nativeLanguage": "en",
    "packageName": "com.mycompany.myapp",
    "packageFolder": "com/mycompany/myapp",
    "prodDatabaseType": "mysql",
    "searchEngine": false,
    "serviceDiscoveryType": false,
    "skipClient": false,
    "skipServer": false,
    "testFrameworks": [
      "protractor"
    ],
    "websocket": false,
    "baseName": "oauth2",
    "authenticationType": "oauth2",
    "buildTool": "gradle",
    "jhipsterVersion": "6.5.1",
    "skipUserManagement": true,
    "clientPackageManager": "npm",
    "applicationType": "monolith",
    "cacheProvider": "ehcache",
    "clientFramework": "angularX",
    "clientTheme": "none",
    "clientThemeVariant": "",
    "serverPort": "8080",
    "useSass": true,
    "embeddableLaunchScript": false,
    "entitySuffix": "",
    "dtoSuffix": "DTO",
    "otherModules": [],
    "blueprints": []
  },
  "entities": []
}

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


JDL entity definitions


Environment and Tools

openjdk version "1.8.0_232"
OpenJDK Runtime Environment (build 1.8.0_232-8u232-b09-1~deb9u1-b09)
OpenJDK 64-Bit Server VM (build 25.232-b09, mixed mode)

git version 2.11.0

node: v12.13.1

npm: 6.13.4

yeoman: 3.1.1

yarn: 1.21.1

INFO! Congratulations, JHipster execution is complete!
`
ps: my OS is Debian9 (stretch)

@Lina-Hammami Failure is about eslint, so I suppose it also fails when you run npm run lint? As a temporary workaround and to confirm there's an issue with eslint could you comment out the eslint-loader rule configuration in webpack/webpack.dev.js like below?

~js
module: {
rules: [ /* {
test: /.(j|t)s$/,
enforce: 'pre',
loader: 'eslint-loader',
exclude: /node_modules/
}, */
~

This is it ! thank you for your help ^^

Fortunately, eslint is not critical for the build process.

I'll try to reproduce the issue on Ubuntu to see if there's something we can do.

@gmarziou any follow up? I'm experiencing the same issue and workaround resolves it. But would like to have eslint working.

Thanks

Sorry, I did not work on it.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

DanielFran picture DanielFran  Â·  3Comments

kaidohallik picture kaidohallik  Â·  3Comments

sdoxsee picture sdoxsee  Â·  4Comments

SudharakaP picture SudharakaP  Â·  3Comments

RizziCR picture RizziCR  Â·  3Comments