Search code examples
visual-studio-codeintellij-ideaidesublimetext

IDE Setup; project package separation


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?


Solution

  • 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.