0

I am on a self learning path into full stack development, and I am not sure how to formulate this question, or if I am using the right terminology here. My apologies for that.

In the process while doing a couple of tutorials, I often end up installing packages and modules required by the tutorial, usually for a specific IDE. This often includes installing a specific package version.

If one project uses packages x,y,z and version a,b,c while another project relies on different packages and or versions, how do you isolate these packages and version between projects in your IDE? How would you prevent “package bleeding” between different projects ?

In other words, how do I prevent writing and testing code for package version 10, while my IDE is using package version 12 because I have installed it somewhere in the past.

In a production environment, whose job is it to setup and maintain the right packages and versions?

starball
  • 20,030
  • 7
  • 43
  • 238
IT Jeroen
  • 13
  • 3
  • what programming language? What package manager? It depends on the package manager. Most package managers will have appropriate mechanisms to keep things separated. – starball Jun 19 '23 at 02:47
  • @starball Full Stack at the moment, so mostly Java Script, (NodeJS, Express, Ruby, React, etc.) VS-Code with Javascript uses NPM Package manager. I've also used SublimeText and Atom in the past and Python with Anaconda or Pycharm. Did a little bit with Java as well using IntelijIDEA – IT Jeroen Jun 19 '23 at 09:28

1 Answers1

0

If one project uses packages x,y,z and version a,b,c while another project relies on different packages and or versions, how do you isolate these packages and version between projects in your IDE? How would you prevent “package bleeding” between different projects ?

It depends on the package manager's design, which can depend in turn on the programming language's design, and how it links with / loads dependencies.

  • Some package managers will just install packages to a project-specific directory, such as NPM, and then the program just looks in that project-specific directory and takes whatever version it finds first according to its dependency resolution strategy. It's a pretty simple way to get what you've described, but it can lead to duplicate installations if two projects both depend on the same thing, which is a bit of a waste of disk space.

  • Some package managers will by default install packages to a non-project-specific directory, and not do anything to separate things by package version (Ex. pip)- making it so you can only install one version of a package on a machine. pip does, however, work with Python's virtual environment feature, which allows you to achieve something similar to the above bullet point.

  • Some package managers will install packages to a non-project-specific directory, separating package versions such that multiple versions can be installed (Ex. Maven, PNPM), and then doing something to the program's setup so that the program knows how to find the correct version.

So basically, consult your package manager and programming language / programming language's implementation's documentation.


In other words, how do I prevent writing and testing code for package version 10, while my IDE is using package version 12 because I have installed it somewhere in the past.

If your IDE is good, it'll (when possible,) notice what version of a package a project is configured to use, and then give you IntelliSense based on that- perhaps with a bit of configuration tinkering.


In a production environment, whose job is it to setup and maintain the right packages and versions?

Depends on the project and how the people want to organize their roles. One size does not fit all. Maybe dev ops. Maybe a build engineer. Maybe a startup intern.

starball
  • 20,030
  • 7
  • 43
  • 238
  • In my case with VS-Code and NPM, it will install a package in the local directory (preferably project root folder) as long as it doesn't have a -g global flag. https://stackoverflow.com/questions/14032160/npm-install-module-in-current-directory#14032346 – IT Jeroen Jun 20 '23 at 03:15