IDE设置;项目包分离

huangapple go评论82阅读模式
英文:

IDE Setup; project package separation

问题

我正在自学全栈开发,不确定如何表达这个问题,或者是否在这里使用了正确的术语。对此我深感抱歉。

在进行一些教程时,我经常需要安装教程所需的包和模块,通常是针对特定的集成开发环境(IDE)。这通常包括安装特定的包版本。

如果一个项目使用了包x、y、z和版本a、b、c,而另一个项目依赖于不同的包和/或版本,你如何在你的IDE中隔离这些包和版本以用于不同的项目?你如何防止不同项目之间的“包冲突”?

换句话说,我如何防止为包版本10编写和测试代码,而我的IDE使用的是包版本12,因为我在过去的某个地方安装了它。

在生产环境中,是谁的责任设置和维护正确的包和版本?

英文:

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?

答案1

得分: 0

  • 一些包管理器会将包安装到特定于项目的目录中,例如NPM,然后程序只会查找该项目特定目录并按照其依赖解析策略选择找到的第一个版本。这是获得您描述的结果的一种相当简单的方式,但如果两个项目都依赖于相同的内容,可能会导致重复安装,这会浪费一些磁盘空间。

  • 一些包管理器默认会将包安装到非特定于项目的目录,并且不会采取任何措施来区分包的版本(例如pip)- 这样一来您只能在一台机器上安装一个版本的包。但是pip可以使用Python的虚拟环境功能,从而使您可以实现与上述要点类似的效果。

  • 一些包管理器会将包安装到非特定于项目的目录中,以不同的包版本分隔开,因此可以安装多个版本(例如Maven,PNPM),然后通过对程序设置某些内容来使程序知道如何找到正确的版本。

因此,基本上要咨询您的包管理器以及编程语言/编程语言实现的文档。


如果您的IDE很好,它会(在可能的情况下)注意到项目配置要使用的包版本,然后根据此为您提供IntelliSense-可能需要进行一些配置调整。


在生产环境中,设置和维护正确的包和版本是谁的工作?

这取决于项目以及人们希望如何组织他们的角色。没有一种方法适用于所有情况。也许是运维人员,也许是构建工程师,也许是初创企业的实习生。

英文:

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

huangapple
  • 本文由 发表于 2023年6月19日 10:43:44
  • 转载请务必保留本文链接:https://go.coder-hub.com/76503322.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定