4

I'm new to jhipster. I am on jhipster v7.8.1, i can generate an app using the cli questions but when i try importing a jdl file i got the following error:

**ERROR! Class constructor GAstVisitor cannot be invoked without 'new' TypeError: Class constructor GAstVisitor cannot be invoked without 'new' at new DslMethodsCollectorVisitor

kk99
  • 37
  • 4
  • 1
    Please try latest version 7.9.2 – Gaël Marziou Aug 19 '22 at 22:18
  • Have upgraded to v7.9.2 recently, also upgraded node.js to v16.17.0. The error raised when I try to update entities with jdl, throws: ERROR! Class constructor GAstVisitor cannot be invoked without 'new' – Harrison Aug 20 '22 at 08:44
  • even when i upgraded the version still not working – kk99 Aug 20 '22 at 11:19
  • 2
    I have reproduced it. This is a blocking bug in the JDL parser, I have opened an issue https://github.com/jhipster/generator-jhipster/issues/19486 – Gaël Marziou Aug 20 '22 at 14:32

2 Answers2

2

This occurs due to a recent bug in the one of JHipster libraries. As a temporary solution you can go to the JHipster installed location and find it's package.json file and override the package causing this error as follows. Then run npm install again.

    "overrides":{
      "chevrotain@10.1.2": {
      "@chevrotain/gast": "10.1.2"
     }
    }

This will prevent the JHipster using latest package of that.

  • in the package.json, i find this: "dependencies": {"@faker-js/faker": "5.5.3","aws-sdk":"2.1106.0","axios": "0.26.1","chalk": "4.1.2","chevrotain": "10.1.2","commander": "9.1.0",.......} but no "overrides" ..... – kk99 Aug 21 '22 at 19:31
  • 1
    From what he said, this is the package.json of the generator, so it should be node_modules\generator-jhipster\package.json in your project. I did not test it though. – Gaël Marziou Aug 21 '22 at 20:17
  • I added these lines in the file but same issue, how should I add them correctly? – kk99 Aug 21 '22 at 20:21
  • yeah , i did find the right file, but it has already the dependency cherveotain with the version 10.1.2 – kk99 Aug 21 '22 at 20:23
  • 1
    @kk99 the problem is with the @chevrotain/gast dependency not chevrotain itself. So after adding the overrides section to the package.json of the generator-jhipster, remove it's node_modules directory and package-lock.json file. Then run npm install within the generator-jhipster directory – Priyantha Buddhika Aug 22 '22 at 14:21
2

I experienced the same error and managed to get the JDL file to run by using version 7.8.1 I followed the following steps to get this done;

  1. uninstall the current version of jhipster that is causing issues for my case this was 7.9.2 . use this command npm uninstall -g generator-jhipster
  2. Install version 7.8.1 using this command npm install -g generator-jhipster@7.8.1
  3. Attempt to run your JDL using this command jhipster jdl jhipster-jdl.jdl
  4. At this stage, your JDL will be able to run
Umar Kayondo
  • 405
  • 4
  • 9