jhipster / generator-jhipster-nodejs

A NodeJS blueprint that creates the backend using NestJS
https://www.npmjs.com/package/generator-jhipster-nodejs
Apache License 2.0
256 stars 79 forks source link

Unexpected logs when creating a new app using import-jdl #159

Closed mraible closed 4 years ago

mraible commented 4 years ago

Describe the bug

I tried creating a new app with the following JDL.

application {
  config {
    applicationType monolith
    baseName HealthPoints
    packageName com.okta.developer
    authenticationType oauth2
    prodDatabaseType postgresql
    buildTool gradle
    testFrameworks [protractor]
    clientFramework react
    useSass true
    enableTranslation true
    nativeLanguage en
    languages [en, es]
  }
  entities Points, BloodPressure, Weight, Preferences
}

entity BloodPressure {
  timestamp ZonedDateTime required
  systolic Integer required
  diastolic Integer required
}

entity Weight {
  timestamp ZonedDateTime required
  weight Double required
}

entity Points {
  date LocalDate required
  exercise Integer
  meals Integer
  alcohol Integer
  notes String maxlength(140)
}

entity Preferences {
  weeklyGoal Integer required min(10) max(21)
  weightUnits Units required
}

enum Units {
  KG,
  LB
}

relationship OneToOne {
  Preferences{user(login)} to User
}

relationship ManyToOne {
  BloodPressure{user(login)} to User,
  Weight{user(login)} to User,
  Points{user(login)} to User
}

paginate BloodPressure, Weight with infinite-scroll
paginate Points with pagination

I'm using Node.js v14.7.0.

To Reproduce

Steps to reproduce the behavior:

  1. Create a nodejs directory and save the above JDL in nodejs/app.jdl
  2. Run nhipster import-jdl app.jdl
  3. See unexpected errors.

The first:

INFO! Generating 1 application.
INFO! Generating application HealthPoints in a new parallel process
(node:84481) Warning: Accessing non-existent property 'cat' of module exports inside circular dependency
(Use `node --trace-warnings ...` to show where the warning was created)
(node:84481) Warning: Accessing non-existent property 'cd' of module exports inside circular dependency
(node:84481) Warning: Accessing non-existent property 'chmod' of module exports inside circular dependency
(node:84481) Warning: Accessing non-existent property 'cp' of module exports inside circular dependency
(node:84481) Warning: Accessing non-existent property 'dirs' of module exports inside circular dependency
(node:84481) Warning: Accessing non-existent property 'pushd' of module exports inside circular dependency
(node:84481) Warning: Accessing non-existent property 'popd' of module exports inside circular dependency
(node:84481) Warning: Accessing non-existent property 'echo' of module exports inside circular dependency
(node:84481) Warning: Accessing non-existent property 'tempdir' of module exports inside circular dependency
(node:84481) Warning: Accessing non-existent property 'pwd' of module exports inside circular dependency
(node:84481) Warning: Accessing non-existent property 'exec' of module exports inside circular dependency
(node:84481) Warning: Accessing non-existent property 'ls' of module exports inside circular dependency
(node:84481) Warning: Accessing non-existent property 'find' of module exports inside circular dependency
(node:84481) Warning: Accessing non-existent property 'grep' of module exports inside circular dependency
(node:84481) Warning: Accessing non-existent property 'head' of module exports inside circular dependency
(node:84481) Warning: Accessing non-existent property 'ln' of module exports inside circular dependency
(node:84481) Warning: Accessing non-existent property 'mkdir' of module exports inside circular dependency
(node:84481) Warning: Accessing non-existent property 'rm' of module exports inside circular dependency
(node:84481) Warning: Accessing non-existent property 'mv' of module exports inside circular dependency
(node:84481) Warning: Accessing non-existent property 'sed' of module exports inside circular dependency
(node:84481) Warning: Accessing non-existent property 'set' of module exports inside circular dependency
(node:84481) Warning: Accessing non-existent property 'sort' of module exports inside circular dependency
(node:84481) Warning: Accessing non-existent property 'tail' of module exports inside circular dependency
(node:84481) Warning: Accessing non-existent property 'test' of module exports inside circular dependency
(node:84481) Warning: Accessing non-existent property 'to' of module exports inside circular dependency
(node:84481) Warning: Accessing non-existent property 'toEnd' of module exports inside circular dependency
(node:84481) Warning: Accessing non-existent property 'touch' of module exports inside circular dependency
(node:84481) Warning: Accessing non-existent property 'uniq' of module exports inside circular dependency
(node:84481) Warning: Accessing non-existent property 'which' of module exports inside circular dependency
INFO! Executing jhipster:app on /Users/mraible/nodejs
INFO! Options: blueprints: nodejs, fromCli: true, withEntities: true, force: true, from-cli: true, with-entities: true
     info Using blueprint generator-jhipster-nodejs for app subgenerator
(node:84484) Warning: Accessing non-existent property 'cat' of module exports inside circular dependency
(Use `node --trace-warnings ...` to show where the warning was created)
(node:84484) Warning: Accessing non-existent property 'cd' of module exports inside circular dependency
(node:84484) Warning: Accessing non-existent property 'chmod' of module exports inside circular dependency
(node:84484) Warning: Accessing non-existent property 'cp' of module exports inside circular dependency
(node:84484) Warning: Accessing non-existent property 'dirs' of module exports inside circular dependency
(node:84484) Warning: Accessing non-existent property 'pushd' of module exports inside circular dependency
(node:84484) Warning: Accessing non-existent property 'popd' of module exports inside circular dependency
(node:84484) Warning: Accessing non-existent property 'echo' of module exports inside circular dependency
(node:84484) Warning: Accessing non-existent property 'tempdir' of module exports inside circular dependency
(node:84484) Warning: Accessing non-existent property 'pwd' of module exports inside circular dependency
(node:84484) Warning: Accessing non-existent property 'exec' of module exports inside circular dependency
(node:84484) Warning: Accessing non-existent property 'ls' of module exports inside circular dependency
(node:84484) Warning: Accessing non-existent property 'find' of module exports inside circular dependency
(node:84484) Warning: Accessing non-existent property 'grep' of module exports inside circular dependency
(node:84484) Warning: Accessing non-existent property 'head' of module exports inside circular dependency
(node:84484) Warning: Accessing non-existent property 'ln' of module exports inside circular dependency
(node:84484) Warning: Accessing non-existent property 'mkdir' of module exports inside circular dependency
(node:84484) Warning: Accessing non-existent property 'rm' of module exports inside circular dependency
(node:84484) Warning: Accessing non-existent property 'mv' of module exports inside circular dependency
(node:84484) Warning: Accessing non-existent property 'sed' of module exports inside circular dependency
(node:84484) Warning: Accessing non-existent property 'set' of module exports inside circular dependency
(node:84484) Warning: Accessing non-existent property 'sort' of module exports inside circular dependency
(node:84484) Warning: Accessing non-existent property 'tail' of module exports inside circular dependency
(node:84484) Warning: Accessing non-existent property 'test' of module exports inside circular dependency
(node:84484) Warning: Accessing non-existent property 'to' of module exports inside circular dependency
(node:84484) Warning: Accessing non-existent property 'toEnd' of module exports inside circular dependency
(node:84484) Warning: Accessing non-existent property 'touch' of module exports inside circular dependency
(node:84484) Warning: Accessing non-existent property 'uniq' of module exports inside circular dependency
(node:84484) Warning: Accessing non-existent property 'which' of module exports inside circular dependency

 ███╗   ██╗ ██╗   ██╗ ████████╗ ███████╗   ██████╗ ████████╗ ████████╗ ███████╗
 ████╗  ██║ ██║   ██║ ╚══██╔══╝ ██╔═══██╗ ██╔════╝ ╚══██╔══╝ ██╔═════╝ ██╔═══██╗
 ██╔██╗ ██║ ████████║    ██║    ███████╔╝ ╚█████╗     ██║    ██████╗   ███████╔╝
 ██║╚██╗██║ ██╔═══██║    ██║    ██╔════╝   ╚═══██╗    ██║    ██╔═══╝   ██╔══██║
 ██║ ╚████║ ██║   ██║ ████████╗ ██║       ██████╔╝    ██║    ████████╗ ██║  ╚██╗
 ╚═╝  ╚═══╝ ╚═╝   ╚═╝ ╚═══════╝ ╚═╝       ╚═════╝     ╚═╝    ╚═══════╝ ╚═╝   ╚═╝

                            https://www.jhipster.tech

Welcome to NHipster (Jhipster NodeJS Official Blueprint) v1.1.0
This blueprint generates your backend in NodeJS with NestJS framework

Why are there so many warnings?

The 2nd:

 ______________________________________________________________________________

  JHipster update available: 6.10.1 (current: 6.8.0)

  Run npm install -g generator-jhipster to update.

 ______________________________________________________________________________

I already have 6.10.1 installed globally. I re-installed it and ran it again to confirm it happens a 2nd time.

The 3rd:

Unable to find src/main/webapp/i18n/en/global.json or missing required jhipster-needle.  Reference to en  not added as a new entity in the menu.

i18n on the frontend should be part of the main generator.

Also, I noticed the latest version of the NHipster uses Keycloak 9. The main generator uses Keycloak 10 so you might want to do a re-sync.

mraible commented 4 years ago

When I try to run my Node.js backend, I get all kinds of errors.

ERROR in ./src/main/webapp/app/shared/layout/menus/entities.tsx
Module Error (from ./node_modules/thread-loader/dist/cjs.js):

/Users/mraible/nodejs/src/main/webapp/app/shared/layout/menus/entities.tsx
  12:8  error  'Translate' is not defined  react/jsx-no-undef
  15:8  error  'Translate' is not defined  react/jsx-no-undef
  18:8  error  'Translate' is not defined  react/jsx-no-undef
  21:8  error  'Translate' is not defined  react/jsx-no-undef

✖ 4 problems (4 errors, 0 warnings)

 @ ./src/main/webapp/app/shared/layout/menus/index.ts 3:0-27 3:0-27
 @ ./src/main/webapp/app/shared/layout/header/header.tsx
 @ ./src/main/webapp/app/app.tsx
 @ ./src/main/webapp/app/index.tsx
npm ERR! code ELIFECYCLE
npm ERR! errno 2
npm ERR! health-points@0.0.1-SNAPSHOT webpack: `node --max_old_space_size=4096 node_modules/webpack/bin/webpack.js "--config" "webpack/webpack.prod.js" "--profile"`
npm ERR! Exit status 2
npm ERR!
npm ERR! Failed at the health-points@0.0.1-SNAPSHOT webpack script.
npm ERR! This is probably not a problem with npm. There is likely additional logging output above.

npm ERR! A complete log of this run can be found in:
npm ERR!     /Users/mraible/.npm/_logs/2020-08-11T05_38_06_382Z-debug.log
npm ERR! code ELIFECYCLE
npm ERR! errno 2
npm ERR! health-points@0.0.1-SNAPSHOT webpack:prod:main: `npm run webpack -- --config webpack/webpack.prod.js --profile`
npm ERR! Exit status 2
npm ERR!
npm ERR! Failed at the health-points@0.0.1-SNAPSHOT webpack:prod:main script.
npm ERR! This is probably not a problem with npm. There is likely additional logging output above.

npm ERR! A complete log of this run can be found in:
npm ERR!     /Users/mraible/.npm/_logs/2020-08-11T05_38_06_421Z-debug.log
npm ERR! code ELIFECYCLE
npm ERR! errno 2
npm ERR! health-points@0.0.1-SNAPSHOT webpack:prod: `npm run cleanup && npm run webpack:prod:main`
npm ERR! Exit status 2
npm ERR!
npm ERR! Failed at the health-points@0.0.1-SNAPSHOT webpack:prod script.
npm ERR! This is probably not a problem with npm. There is likely additional logging output above.

npm ERR! A complete log of this run can be found in:
npm ERR!     /Users/mraible/.npm/_logs/2020-08-11T05_38_06_441Z-debug.log
npm ERR! code ELIFECYCLE
npm ERR! errno 2
npm ERR! health-points@0.0.1-SNAPSHOT build: `npm run webpack:prod`
npm ERR! Exit status 2
npm ERR!
npm ERR! Failed at the health-points@0.0.1-SNAPSHOT build script.
npm ERR! This is probably not a problem with npm. There is likely additional logging output above.

npm ERR! A complete log of this run can be found in:
npm ERR!     /Users/mraible/.npm/_logs/2020-08-11T05_38_06_458Z-debug.log
npm ERR! code ELIFECYCLE
npm ERR! errno 2
npm ERR! health-points@0.0.1-SNAPSHOT start:app: `npm run build && cd server && npm run start`
npm ERR! Exit status 2
npm ERR!
npm ERR! Failed at the health-points@0.0.1-SNAPSHOT start:app script.
npm ERR! This is probably not a problem with npm. There is likely additional logging output above.

npm ERR! A complete log of this run can be found in:
npm ERR!     /Users/mraible/.npm/_logs/2020-08-11T05_38_06_481Z-debug.log

I'll try re-generating without i18n.

mraible commented 4 years ago

Doh! It fails when I remove the last 3 keys from the main configuration. New JDL:

application {
  config {
    applicationType monolith
    baseName HealthPoints
    packageName com.okta.developer
    authenticationType oauth2
    prodDatabaseType postgresql
    buildTool gradle
    testFrameworks [protractor]
    clientFramework react
    useSass true
  }
  entities Points, BloodPressure, Weight, Preferences
}

entity BloodPressure {
  timestamp ZonedDateTime required
  systolic Integer required
  diastolic Integer required
}

entity Weight {
  timestamp ZonedDateTime required
  weight Double required
}

entity Points {
  date LocalDate required
  exercise Integer
  meals Integer
  alcohol Integer
  notes String maxlength(140)
}

entity Preferences {
  weeklyGoal Integer required min(10) max(21)
  weightUnits Units required
}

enum Units {
  KG,
  LB
}

relationship OneToOne {
  Preferences{user(login)} to User
}

relationship ManyToOne {
  BloodPressure{user(login)} to User,
  Weight{user(login)} to User,
  Points{user(login)} to User
}

paginate BloodPressure, Weight with infinite-scroll
paginate Points with pagination

Result:

> HealthPoints@0.0.1 start /Users/mraible/nodejs/server
> npm run clean && npm run copy-resources && nodemon --watch src -e ts,tsx --exec ts-node src/main.ts

> HealthPoints@0.0.1 clean /Users/mraible/nodejs/server
> rimraf dist

> HealthPoints@0.0.1 copy-resources /Users/mraible/nodejs/server
> ts-node scripts/copy-resources.ts

sh: ts-node: command not found
npm ERR! code ELIFECYCLE
npm ERR! syscall spawn
npm ERR! file sh
npm ERR! errno ENOENT
npm ERR! HealthPoints@0.0.1 copy-resources: `ts-node scripts/copy-resources.ts`
npm ERR! spawn ENOENT
npm ERR!
npm ERR! Failed at the HealthPoints@0.0.1 copy-resources script.
npm ERR! This is probably not a problem with npm. There is likely additional logging output above.
npm WARN Local package.json exists, but node_modules missing, did you mean to install?

npm ERR! A complete log of this run can be found in:
npm ERR!     /Users/mraible/.npm/_logs/2020-08-11T05_42_09_329Z-debug.log
npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! HealthPoints@0.0.1 start: `npm run clean && npm run copy-resources && nodemon --watch src -e ts,tsx --exec ts-node src/main.ts`
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the HealthPoints@0.0.1 start script.
npm ERR! This is probably not a problem with npm. There is likely additional logging output above.
npm WARN Local package.json exists, but node_modules missing, did you mean to install?

npm ERR! A complete log of this run can be found in:
npm ERR!     /Users/mraible/.npm/_logs/2020-08-11T05_42_09_351Z-debug.log
npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! health-points@0.0.1-SNAPSHOT start:app: `npm run build && cd server && npm run start`
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the health-points@0.0.1-SNAPSHOT start:app script.
npm ERR! This is probably not a problem with npm. There is likely additional logging output above.

npm ERR! A complete log of this run can be found in:
npm ERR!     /Users/mraible/.npm/_logs/2020-08-11T05_42_09_373Z-debug.log
Execution time: 24 s.
mraible commented 4 years ago

Just realized this happens because I didn't run npm install. I think the printed text should be improved to say:

Run your application (after npm install in root folder and server folder) :
 npm i && cd server && npm i
 npm run start:app
Otherwise, run the npm scripts explained under README.md and server/README.md
mraible commented 4 years ago

After getting it all up and running, I started Keycloak using Docker Compose. When I click sign in on the homepage, it results in the following error.

Error: Maximum update depth exceeded. This can happen when a component repeatedly calls setState inside componentWillUpdate or componentDidUpdate. React limits the number of nested updates to prevent infinite loops.

    in Lifecycle (created by Context.Consumer)
    in Redirect (created by Context.Consumer)
    in Route (created by PrivateRouteComponent)
    in PrivateRouteComponent (created by Connect(PrivateRouteComponent))
    in Connect(PrivateRouteComponent) (created by Routes)
    in Switch (created by Routes)
    in div (created by Routes)
    in Routes (created by App)
    in ErrorBoundary (created by App)
    in div (created by Card)
    in Card (created by App)
    in div (created by App)
    in div (created by App)
    in Router (created by BrowserRouter)
    in BrowserRouter (created by App)
    in App (created by HotExportedApp)
    in AppContainer (created by HotExportedApp)
    in HotExportedApp (created by ConnectFunction)
    in ConnectFunction
    in div
    in Provider
    in ErrorBoundary
Screen Shot 2020-08-10 at 11 53 41 PM
ghost commented 4 years ago

Hi @mraible , thanks for the feedbacks! So the error for i18n, is due to the feature not implemented for nhipster (see #119 , @Aragonbn90 has the issue in progress).

Just realized this happens because I didn't run npm install. I think the printed text should be improved to say:

Run your application (after npm install in root folder and server folder) :
 npm i && cd server && npm i
 npm run start:app
Otherwise, run the npm scripts explained under README.md and server/README.md

The reason is that there are some mode to run the application with the scripts explained in README. For the last, it seems an error of react client maybe for the previous wrong generation.

Please try these steps:

ghost commented 4 years ago

Just realized this happens because I didn't run npm install. I think the printed text should be improved to say:

Run your application (after npm install in root folder and server folder) :
 npm i && cd server && npm i
 npm run start:app
Otherwise, run the npm scripts explained under README.md and server/README.md

Maybe I could replace this log with:

Run your application: npm i && cd server && npm i && cd .. && npm run start:app Otherwise, run the npm scripts explained under README.md and server/README.md

How do you say, Matt?

ghost commented 4 years ago

Hi @mraible , I have improved the generator with i18n feature that fixes the error with your jdl. Besides I have added also it in nhipster integration tests, so it's all ok! : https://github.com/jhipster/generator-jhipster-nodejs/blob/master/test-integration/samples/monolith-react-oauth2-i18n-jdl/monolith-react-oauth2-i18n-jdl.jdl