Help us understand the problem. What is going on with this article?

Phoenix Frameworkをインストール

More than 5 years have passed since last update.

Elixirの代表的なwebフレームワークであるPhoenix Frameworkをインストールする。

Phoenix Frameworkをインストール

$ mix local.hex
$ mix archive.install https://github.com/phoenixframework/phoenix/releases/download/v0.13.1/phoenix_new-0.13.1.ez

プロジェクト作成

$ mix phoenix.new hello_phoenix
* creating hello_phoenix/config/config.exs
... いろいろ表示 ...
* creating hello_phoenix/priv/static/images/phoenix.png

Fetch and install dependencies? [Yn] Y

Phoenix uses an optional assets build tool called brunch.io
that requires node.js and npm. Installation instructions for
node.js, which includes npm, can be found at http://nodejs.org.

After npm is installed, install your brunch dependencies by
running inside your app:

    $ npm install

If you don't want brunch.io, you can re-run this generator
with the --no-brunch option.


We are all set! Run your Phoenix application:

    $ cd hello_phoenix
    $ mix deps.get
    $ mix phoenix.server

You can also run it inside IEx (Interactive Elixir) as:

    $ iex -S mix phoenix.server

サーバー起動

$ cd hello_phoenix
$ mix phoenix.server
==> fs (compile)
Compiled src/sys/inotifywait.erl
Compiled src/sys/fsevents.erl
Compiled src/sys/inotifywait_win32.erl

... いろいろ表示 ...

Compiled web/views/layout_view.ex
Generated hello_phoenix app
[info] Running HelloPhoenix.Endpoint with Cowboy on port 4000 (http)

module.js:340
    throw err;
          ^
Error: Cannot find module 'hello_phoenix/node_modules/brunch/bin/brunch'
    at Function.Module._resolveFilename (module.js:338:15)
    at Function.Module._load (module.js:280:25)
    at Module.runMain (module.js:492:10)
    at process.startup.processNextTick.process._tickCallback (node.js:244:9)

brunch.ioがないよと、起動時にエラーがでてしまう。

ブラウザでアクセスしたら、表示が変になってしまっている。

今回はphoenix frameworkを動かしてみたいだけなので、
プロジェクト作成時に以下のように表示された通り、--no-braunchをつけて、再度プロジェクトを作成する。

If you don't want brunch.io, you can re-run this generator
with the --no-brunch option.

再度プロジェクト作成

$ cd ..
$ rm -r hello_phoenix/
$ mix phoenix.new hello_phoenix --no-brunch

再度サーバー起動

$ cd hello_phoenix/
$ mix phoenix.server
==> fs (compile)
Compiled src/sys/inotifywait_win32.erl
... いろいろ ...
Compiled lib/hello_phoenix/endpoint.ex
Generated hello_phoenix app
[info] Running HelloPhoenix.Endpoint with Cowboy on port 4000 (http)

localhost:4000にアクセス

ターミナル上

[info] GET /
[info] Processing by HelloPhoenix.PageController.index/2
  Parameters: %{"format" => "html"}
  Pipelines: [:browser]
[info] Sent 200 in 7ms

ブラウザ表示

Kobito.npD51r.png

今度はちゃんと表示される。

spacemarket
「世界中のあらゆるスペースをシェアできるプラットフォームを創る」のミッションのもと、スペースを1時間単位で簡単に予約できる「スペースマーケット」等を運営しています。
https://spacemarket.co.jp
Why not register and get more from Qiita?
  1. We will deliver articles that match you
    By following users and tags, you can catch up information on technical fields that you are interested in as a whole
  2. you can read useful information later efficiently
    By "stocking" the articles you like, you can search right away
Comments
No comments
Sign up for free and join this conversation.
If you already have a Qiita account
Why do not you register as a user and use Qiita more conveniently?
You need to log in to use this function. Qiita can be used more conveniently after logging in.
You seem to be reading articles frequently this month. Qiita can be used more conveniently after logging in.
  1. We will deliver articles that match you
    By following users and tags, you can catch up information on technical fields that you are interested in as a whole
  2. you can read useful information later efficiently
    By "stocking" the articles you like, you can search right away
ユーザーは見つかりませんでした