In a jQuery, jQueryUI, bootstrap type library project, I put it in the lib folder. What is the proper practice of committing such a project? Do I need to add the lib folder to the commit?

Or perhaps it is better to install jQuery and other libraries through npm into the node_modules folder, include node_modules in gitignore, and restore the contents of node_modules via npm install?

  • one
    node_modules , if used, must be in gitignore, and using it or not is a personal matter for everyone, I think I don’t use) - andreymal
  • It's clear. The question is what is the best practice for commits of folders with used third-party libraries (such as jquery). Are they included in a commit or not? - const
  • Definitely NO! All dependencies are in package.json - Nazar Kalytiuk

1 answer 1

jQuery and other libraries are externally dependent. Include them in your project you need using a dependency manager . That is, the dependency itself does not fall into your repository, but only the link to it falls.

When building a project , the dependency manager will find the desired artifact (s) and connect it (them) to your project.

There are many dependency managers , here are some

  • Thanks for the answer. Tell me, please, which dependency managers are now recommended for use? - const
  • 2
    This question is difficult to answer objectively. since everyone praises their favorite manager and scolds the rest. I will add a list to the answer, but will not give them a rating. - Mikhail Vaysman
  • Thanks for the answer. Additional questions about this. In the project, backend is implemented on Node.js. The management of backend modules, of course, is done using npm. Is it right to use npm also to manage frontend libraries? In this case, the frontend libraries will fall into the same node_modules folder as the backend modules will be registered in one package.json file with backend modules. This is a normal practice then both backend and frontend dependencies fall into the same node_modules folder, and links to them in the same package.json file? - const
  • one
    Yes. so you can do. but it will be better to use CDN versions of libraries in combat mode. - Mikhail Vaysman
  • Those. CDN is preferable to the location of the libraries on the application server? And in this case, there is generally no need to store anywhere in the frontend-dependency project. - const