Generator-jhipster: Having jHipster 2.x and 3.x on same dev computer

Created on 25 Mar 2016  路  8Comments  路  Source: jhipster/generator-jhipster

Overview of the issue

We have 2 jHipster 2.x in production and still under heavy dev ... And muist bootstrap a new one (so we go 3.0 !) : how can we manage both env (as i'll need to continue using the entity generator and cloudfoundry deployement script for our 2.x projects) ?

I think it's a major issue for the future as the project growth (and u all must be thanks for the job done so far !) : we must be able to maintain our old project (i'm ok to make the update effort, but not for a 3.0 release, as it's not really production ready ... But i can't even discover the new jhipster, having the risk to loose the hability to work on my oldest projects !)

Motivation for or Use Case

If i update my jHipster module in 3.0 : i will loose 2.0 project script (mainly entity generator) !

JHipster Version(s)

2.27 and 3.0

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

N.C.

Suggest a Fix

How about having an abstract (lot of work) inside jhipster call to go through version and a param to ask for a specific version ? yo jhipster:.... -version=xx

OR

when changing major ... Create new keywork and keeping old one (yo jhipster3:...., yo:jhipster2:....) ?

OR

I must go myself for VM or even better Docker dev env :D ?

Most helpful comment

try: npm install -g [email protected]
replace X.Y.Z by the version you want

All 8 comments

2 "easy" solutions:

  • Use our Docker installation, that's one of its main usage for me
  • Use one "devbox" per project

Now here is how I work, I find it very good but I'm not sure it's good for everyone else:

  • I have a clone of the project, and did an "npm link" to it
  • When I want to use another version (which happens all the time as I do maintenance work and tests), I use the tag or branch I need
  • Then I just do a "npm install" to be sure to have the dependencies

@lourai its really not within our control as its an npm thing. and there is nothing much we can do except what Julien said above as your suggestion are not practical (we are not a company making money with this you know to do that kind of maintenance)

One thing we did and hoped to work was we had yo and generator-jhipster in the dependency of the generated projects package json and i theory node should use the local version first before using a global so you can try the below and let us know if it works

  1. install Jhipster 2.x with -g
  2. create an app with that and run npm i on it
  3. install Jhipster 3.0 with -g
  4. create an app with that and run npm i on it
  5. now go to the 2.x app and run yo jhipster again and see what version it shows ideally it should use the local jhipster instance

but this means all your new projects will use JH3.0 only existing 2.x might work

plz try and let us know

I want to add to the above suggestions an alternative: use a node environment manager (e.g. nvm on Linux, nodist on Windows) to install 2 different versions of node: one for JH 3 and one for JH 2.

@deepu105 : your 5th step should upgrade the project, so don't yo jhipster on old project.
But the yo jhipster:<module> should use the module inside node_modules/generator-jhipster, which means the old version

So for me, there is no issue here

OK so I was just playing around and this actually works as expected, so you of course can generate entities on a generator based on what version you used to create it

By default NPM will use the local instance of the generator in the node_modules folder

  1. install Jhipster 2.x with -g
  2. create an app with that and run npm i on it
  3. install Jhipster 3.0 with -g
  4. create an app with that and run npm i on it
  5. now go to the 2.x app and run yo jhipster again and see what version it shows ideally it should use the local jhipster instance, do not proceed and just terminate the command
  6. now run yo jhipster:entity to create more entities

I Got the same issue. I have solved it by doing following, little updation in above process.

  1. Install Jhipster 2.x with -g
  2. Go to your app run npm i on it
  3. To generate entity use yo path_of_generator_jhipster_entity entity_name
    e.g. I used yo /usr/local/lib/node_modules/generator-jhipster/entity test

And above process worked successfully for me.

Can you paste exact command to download jhipster 2.x version ?

try: npm install -g [email protected]
replace X.Y.Z by the version you want

Was this page helpful?
0 / 5 - 0 ratings

Related issues

sdoxsee picture sdoxsee  路  4Comments

RizziCR picture RizziCR  路  3Comments

DanielFran picture DanielFran  路  3Comments

edvjacek picture edvjacek  路  3Comments

pascalgrimaud picture pascalgrimaud  路  4Comments