简体   繁体   English

在Elixir中安装依赖项

[英]Installing dependencies in Elixir

Is there a way to install a dependency for an Elixir project directly through the command line using mix or mix hex ? 有没有办法使用mixmix hex直接通过命令行为Elixir项目安装依赖项?

I am aware of the option for searching the hex registry via 我知道通过搜索hex注册表的选项

$ mix hex.search httpoison

Package    Version  URL
httpoison  0.11.0   https://hex.pm/packages/httpoison

However, I am looking for something like 但是,我正在寻找类似的东西

$ mix hex.install httpoison

which will modify my mix.exs file, adding the name and most recent version of the dependency to the deps function and the application name to the applications list and then run 这将修改我的mix.exs文件,将依赖项的名称和最新版本添加到deps函数,将应用程序名称添加到applications列表,然后运行

$ mix deps.get

to pull and compile the dependency. 拉取和编译依赖项。

It sounds like you are looking for something similar to npm install --save . 听起来你正在寻找类似于npm install --save东西。 This feature does not exist in mix. 混合中不存在此功能。 You can install something the usual way by adding it to mix.exs and running mix deps.get as you mention. 您可以通过将其添加到mix.exs并运行mix deps.get来按常规方式安装。

The other way you may wish to install certain applications is via a mix archive allowing this mix task to be run globally. 您可能希望安装某些应用程序的另一种方法是通过混合存档,允许此混合任务全局运行。 One example of this is phoenix.new for creating new phoenix applications which can be installed by running: 其中一个例子是phoenix.new用于创建新的phoenix应用程序,可以通过运行来安装:

mix archive.install https://github.com/phoenixframework/phoenix/releases/download/v0.16.1/phoenix_new-0.16.1.ez

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM