Home » vue » How should I handle different versions of JS libraries in different branches? [duplicate]

How should I handle different versions of JS libraries in different branches? [duplicate]

Posted by: admin November 26, 2021 Leave a comment


I am an amateur developer and code some applications for home use. I use the Quasar framework for the front and Python for the back.

I have a git repository where master holds my "production code" and I would like to try the new version of Quasar (which uses Vue 3).

My principal concern is about how to deal with the new dependences this new framework will bring.

The framework is bootstrapped through quasar create testvue3 --branch next, which does all kinds of magical things, including installing npm libraries.

My understanding is that these libraries go into node_modules, which is not checked in (it is in .gitignore).

My question: how should I switch between the master and v2 branch (the one I will re-bootstrap my frontend on) when it comes to dependencies?

  • should I check in node_modules?
  • or npm install when switching branches?
  • or something else?

Note: Should "node_modules" folder be included in the git repository was suggested as a duplicate. While it has very useful information, it does not answer my question on how to deal with different branches (specifically how to switch between them and recover the right environment, library-wise)


Different branches may contain different content for the package.json, either more/less dependencies or another version for the same ones. Therefore, when checking another branch is important to run npm install to make sure the required dependencies are installed on your local environment. In case that no change is detected the output of install command will return that nothing has been changed. The IDE may even help you out and suggest to run it only when needed as it is the case for WebStorm. To consider:

  1. Check package.json and package-lock.json into Git but not node_modules (it’s huge!)
  2. When adding a dependency make sure to git commit all the changes to these two files
  3. Whenever a branch is changed run npm install to make sure dependency requirements are met