generator-jhipster: import-jdl throws SyntaxError

  • Overview of the request

I generated a jhipster app using the default answers to all questions. I then went to the JDL Studio site and downloaded the example. Without changing the downloaded .jh file, I attempted to import the jdl but got the following error:

▶ yo -v jhipster:import-jdl ./jhipster-jdl.jh
/home/mhalma/dev/ws/jdl-test/jhipster-jdl.jh:2
entity Region {
       ^^^^^^

SyntaxError: Unexpected identifier
    at exports.runInThisContext (vm.js:53:16)
    at Module._compile (module.js:373:25)
    at Object.Module._extensions..js (module.js:416:10)
    at Module.load (module.js:343:32)
    at Function.Module._load (module.js:300:12)
    at Module.require (module.js:353:17)
    at require (internal/module.js:12:17)
    at Object.defineProperty.get [as jhipster-jdl] (/usr/lib/node_modules/yo/node_modules/yeoman-environment/lib/store.js:40:23)
    at Store.get (/usr/lib/node_modules/yo/node_modules/yeoman-environment/lib/store.js:64:35)
    at Environment.get (/usr/lib/node_modules/yo/node_modules/yeoman-environment/lib/environment.js:259:21)

  • Motivation for or Use Case

I’m just trying out JDL Studio.

  • Version Info

OS: Centos 7.

node: 4.4.3 npm: 3.9.3 yo: 1.8.3 generator-jhipster: 3.3.0

▶ cat .yo-rc.json 
{
  "generator-jhipster": {
    "jhipsterVersion": "3.3.0",
    "baseName": "jhipster",
    "packageName": "io.footd",
    "packageFolder": "io/footd",
    "serverPort": "8080",
    "authenticationType": "session",
    "hibernateCache": "ehcache",
    "clusteredHttpSession": "no",
    "websocket": "no",
    "databaseType": "sql",
    "devDatabaseType": "h2Disk",
    "prodDatabaseType": "postgresql",
    "searchEngine": "no",
    "buildTool": "maven",
    "enableSocialSignIn": false,
    "rememberMeKey": "7e73e1116ebf868faf8246752e22c8f71f0b8c36",
    "useSass": false,
    "applicationType": "monolith",
    "testFrameworks": [
      "gatling"
    ],
    "jhiPrefix": "jhi",
    "enableTranslation": false
  }
}% 
▶ cat jhipster-jdl.jh 

entity Region {
    regionId Long,
    regionName String
}

entity Country {
    countryId Long,
    countryName String
}

entity Location {
    locationId Long,
    streetAddress String,
    postalCode String,
    city String,
    stateProvince String
}

entity Department {
    departmentId Long,
    departmentName String required
}

entity Task {
    taskId Long,
    title String,
    description String
}

/**
 * The Employee entity.
 */
entity Employee {
    employeeId Long,
    /**
    * The firstname attribute.
    */
    firstName String,
    lastName String,
    email String,
    phoneNumber String,
    hireDate ZonedDateTime,
    salary Long,
    commissionPct Long
}

entity Job {
    jobId Long,
    jobTitle String,
    minSalary Long,
    maxSalary Long
}

entity JobHistory {
    startDate ZonedDateTime,
    endDate ZonedDateTime,
    language Language
}

enum Language {
    FRENCH, ENGLISH, SPANISH
}

relationship OneToOne {
    Country{region} to Regioncool
}

relationship OneToOne {
    Location{country} to Country
}

relationship OneToOne {
    Department{location} to Location
}

relationship ManyToMany {
    Job{task(title)} to Task{job}
}

relationship OneToMany {
    Employee{job} to Job
}

relationship OneToMany {
    /**
    * A relationship
    */
    Department{employee} to
    /**
    * Another side of the same relationship
    */
    Employee
}

relationship ManyToOne {
    Employee{manager} to Employee
}

relationship OneToOne {
    JobHistory{job} to Job
}

relationship OneToOne {
    JobHistory{department} to Department
}

relationship OneToOne {
    JobHistory{employee} to Employee
}

paginate JobHistory, Employee with infinite-scroll
paginate Job with pagination

dto Employee with mapstruct

service Employee with serviceClass

    %  
  • Suggest a Fix

I fear I am doing something stupid as this most basic of tests should work out of the box?

About this issue

  • Original URL
  • State: closed
  • Created 8 years ago
  • Comments: 15 (7 by maintainers)

Most upvoted comments

I’ve been using the import-jdlfor some time and now I’m having the same issue on my local machine and also on a vagrant box I just created.

On this latest test I’m using the default model that comes when you open the JDL Studio.

  • Created vagrant box
  • Open vagrant box
  • Open terminal
  • Run yo jhipster
  • Save default JDL Studio to .jhipster/model.jh
  • Run yo -v jhipster:import-jdl .jhipster/model.jh

Error output

vagrant@vagrant-ubuntu-trusty-64:~/model$ yo -v jhipster:import-jdl .jhipster/model.jh 
/home/vagrant/model/.jhipster/model.jh:2
entity Region {
       ^^^^^^

SyntaxError: Unexpected identifier
    at exports.runInThisContext (vm.js:53:16)
    at Module._compile (module.js:373:25)
    at Object.Module._extensions..js (module.js:416:10)
    at Module.load (module.js:343:32)
    at Function.Module._load (module.js:300:12)
    at Module.require (module.js:353:17)
    at require (internal/module.js:12:17)
    at Object.defineProperty.get [as .jhipster:model] (/usr/lib/node_modules/yo/node_modules/yeoman-environment/lib/store.js:40:23)
    at Store.get (/usr/lib/node_modules/yo/node_modules/yeoman-environment/lib/store.js:64:35)
    at Environment.get (/usr/lib/node_modules/yo/node_modules/yeoman-environment/lib/environment.js:259:21)
vagrant@vagrant-ubuntu-trusty-64:~/model$ 

.yo-rc.json

{
  "generator-jhipster": {
    "jhipsterVersion": "3.4.0",
    "baseName": "climber",
    "packageName": "com.climber",
    "packageFolder": "com/climber",
    "serverPort": "8080",
    "authenticationType": "jwt",
    "hibernateCache": "ehcache",
    "clusteredHttpSession": "no",
    "websocket": "no",
    "databaseType": "sql",
    "devDatabaseType": "h2Memory",
    "prodDatabaseType": "postgresql",
    "searchEngine": "no",
    "buildTool": "gradle",
    "enableSocialSignIn": false,
    "jwtSecretKey": "0e0d11f8c517aa33f0a4c7a250a3d34dad190979",
    "useSass": false,
    "applicationType": "monolith",
    "testFrameworks": [
      "gatling"
    ],
    "jhiPrefix": "jhi",
    "enableTranslation": true,
    "nativeLanguage": "en",
    "languages": [
      "en"
    ]
  }