Elixir & Phoenix v1.5.9 getting started on Windows 10.

Brooklin Myers
Geek Culture
Published in
4 min readJun 5, 2021

Prerequisites

To run a Phoenix project on your Windows 10 machine, you should install:

  • Node js
  • Elixir & Erlang
  • Hex
  • The Phoenix application generator
  • PostgreSQL

Install Node

You probably already have Node if you’re working on other projects, but if not, you can download a node installer for Windows 10.

Install Elixir and Erlang

You can install Elixir and Erlang by downloading an installer or using chocolatey (a package manager for windows)

cinst elixir

Install Hex

  • In your PowerShell run:
mix local.hex

Install Phoenix application generator

  • In your PowerShell run:
mix archive.install hex phx_new 1.5.9

Install PostgreSQL

PostgreSQL is a database management tool. Later you will configure it with Ecto in Phoenix to run your project’s database.

Make sure to remember the password you choose for your PostgreSQL superuser. You will use this password to configure the phoenix dev.exs file later.

After installing PostgreSQL, you might be prompted to use the Stack Application Builder to install other add-on software. For the phoenix project, you do not need any other packages and can skip this dialogue.

You may need to restart your computer after you install PostgreSQL.

Start a new Phoenix Project.

Now that you have the prerequisites installed, you can generate and configure a new phoenix project. Once you’re done this section, you will have a newly created Phoenix project running on localhost:4000

Generate a new Phoenix project

  • In your PowerShell run:
mix phx.new project_name

you can replace project_name with whatever you want your new project to be. Phoenix only allows project names with lowercase letters, numbers, and underscores.

Install modules

  • In your PowerShell inside of the /assets folder, run:
npm install

Here I got an error.

Can't find Python executable "python", you can set the PYTHON env variable.

However, I do have python on my computer. I found other developers having the issue and discovered the node-sass library caused this. If you have the same issue, you can replace node-sass with sass to fix the problem

  • go into your assets/package.json and replace the node-sass package with sass.
  • In your PowerShell inside of the /assets folder run
npm install

Run webpack

  • In your PowerShell in the /assets folder, run:
node node_modules/webpack/bin/webpack.js --mode development

Configure your Ecto Database with PostgreSQL

Ecto handles data validation and persistence for Phoenix projects. It has built-in integration for PostgreSQL by default. It can also work with other database tools such as MySQL and MSSQL.

  • In your dev.exs file, change the password and username to match your PostgreSQL superuser. I made my password supersecret for the sake of this article, and the default username for PostgreSQL is postgres.

Create your Ecto database

  • In your PowerShell run:
mix ecto.create

Hopefully, this should run successfully. However, If you get a connection refused error, you probably have a PostgreSQL issue. Likely you either have the wrong password, or PostgreSQL is not properly installed.

Start the server

  • In your PowerShell run:
mix phx.server

Open the project in your browser

  • Open your preferred browser (I use Google Chrome)
  • go to localhost:4000

You should see your project up and running!

I hope this helped you get your phoenix project up and running! Expect more articles on Phoenix and Elixir in the future, and if you enjoyed this article, I’d appreciate a comment or clap!

If you have any issues following the article, please comment, and I will do my best to help.

--

--

Brooklin Myers
Geek Culture

Software Engineer. I create educational content focused on technology for mobile and web applications.