我是凤凰和不老药的新手。我正在创建一个phoenix Web服务器作为后端API服务器。我遵循了phoenix框架网站上给出的步骤。
软件版本:
Erlang / OTP 21 [erts-10.2.4] [源代码] [64位] [smp:4:4] [ds:4:4:10] [异步线程:1] [hipe] >
Elixir 1.8.1(与Erlang / OTP 20编译)
Phoenix v1.4.0-dev
和部门
{:phoenix, github: "phoenixframework/phoenix", override: true},
{:phoenix_pubsub, "~> 1.0"},
{:phoenix_ecto, "~> 3.2"},
{:postgrex, ">= 0.0.0"},
{:phoenix_html, "~> 2.11"},
{:phoenix_live_reload, "~> 1.0", only: :dev},
{:gettext, "~> 0.11"},
{:jason, "~> 1.0"},
{:cowboy, "~> 1.0"}
当我尝试运行mix phx.server
时,出现以下错误:
[info] Application hello exited: Hello.Application.start(:normal, []) returned an error: shutdown: failed to start child: HelloWeb.Endpoint
** (EXIT) an exception was raised:
** (UndefinedFunctionError) function Plug.Cowboy.child_spec/1 is undefined (module Plug.Cowboy is not available)
Plug.Cowboy.child_spec([scheme: :http, plug: {HelloWeb.Endpoint, []}, options: [dispatch: [_: [{"/phoenix/live_reload/socket/websocket", Phoenix.Endpoint.CowboyWebSocket, {Phoenix.Transports.WebSocket, {HelloWeb.Endpoint, Phoenix.LiveReloader.Socket, [path: "/websocket", serializer: [{Phoenix.Socket.V1.JSONSerializer, "~> 1.0.0"}, {Phoenix.Socket.V2.JSONSerializer, "~> 2.0.0"}], timeout: 60000, transport_log: false, compress: false]}}}, {"/socket/websocket", Phoenix.Endpoint.CowboyWebSocket, {Phoenix.Transports.WebSocket, {HelloWeb.Endpoint, HelloWeb.UserSocket, [path: "/websocket", serializer: [{Phoenix.Socket.V1.JSONSerializer, "~> 1.0.0"}, {Phoenix.Socket.V2.JSONSerializer, "~> 2.0.0"}], timeout: 60000, transport_log: false, compress: false]}}}, {:_, Plug.Adapters.Cowboy.Handler, {HelloWeb.Endpoint, []}}]], port: 4000, otp_app: :hello]])
(phoenix) lib/phoenix/endpoint/cowboy_adapter.ex:96: Phoenix.Endpoint.CowboyAdapter.child_spec/3
(phoenix) lib/phoenix/endpoint/supervisor.ex:108: anonymous fn/6 in Phoenix.Endpoint.Supervisor.server_children/4
(elixir) lib/enum.ex:1940: Enum."-reduce/3-lists^foldl/2-0-"/3
(phoenix) lib/phoenix/endpoint/supervisor.ex:99: Phoenix.Endpoint.Supervisor.server_children/4
(phoenix) lib/phoenix/endpoint/supervisor.ex:59: Phoenix.Endpoint.Supervisor.init/1
(stdlib) supervisor.erl:295: :supervisor.init/1
(stdlib) gen_server.erl:374: :gen_server.init_it/2
(stdlib) gen_server.erl:342: :gen_server.init_it/6
(stdlib) proc_lib.erl:249: :proc_lib.init_p_do_apply/3
我尝试将牛仔版本更改为2.6.3(根据Brew似乎是最新的),但仍然出现相同的错误。
请帮助我解决这个问题。
-谢谢, 沙伊拉