{"componentChunkName":"component---src-templates-lesson-js","path":"/phoenix-chat/installing-phoenix-and-react","result":{"data":{"mdx":{"body":"function _extends() { _extends = Object.assign || function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; return _extends.apply(this, arguments); }\n\nfunction _objectWithoutProperties(source, excluded) { if (source == null) return {}; var target = _objectWithoutPropertiesLoose(source, excluded); var key, i; if (Object.getOwnPropertySymbols) { var sourceSymbolKeys = Object.getOwnPropertySymbols(source); for (i = 0; i < sourceSymbolKeys.length; i++) { key = sourceSymbolKeys[i]; if (excluded.indexOf(key) >= 0) continue; if (!Object.prototype.propertyIsEnumerable.call(source, key)) continue; target[key] = source[key]; } } return target; }\n\nfunction _objectWithoutPropertiesLoose(source, excluded) { if (source == null) return {}; var target = {}; var sourceKeys = Object.keys(source); var key, i; for (i = 0; i < sourceKeys.length; i++) { key = sourceKeys[i]; if (excluded.indexOf(key) >= 0) continue; target[key] = source[key]; } return target; }\n\n/* @jsx mdx */\nvar _frontmatter = {\n  \"title\": \"Installing Phoenix and React\",\n  \"order\": 1,\n  \"free\": true,\n  \"active\": true,\n  \"tech\": [\"phoenix\", \"react\"]\n};\n\nvar makeShortcode = function makeShortcode(name) {\n  return function MDXDefaultShortcode(props) {\n    console.warn(\"Component \" + name + \" was not imported, exported, or provided by MDXProvider as global scope\");\n    return mdx(\"div\", props);\n  };\n};\n\nvar layoutProps = {\n  _frontmatter: _frontmatter\n};\nvar MDXLayout = \"wrapper\";\nreturn function MDXContent(_ref) {\n  var components = _ref.components,\n      props = _objectWithoutProperties(_ref, [\"components\"]);\n\n  return mdx(MDXLayout, _extends({}, layoutProps, props, {\n    components: components,\n    mdxType: \"MDXLayout\"\n  }), mdx(\"h1\", null, \"Installing Phoenix and React\"), mdx(\"ul\", null, mdx(\"li\", {\n    \"parentName\": \"ul\"\n  }, \"Install Phoenix\"), mdx(\"li\", {\n    \"parentName\": \"ul\"\n  }, \"Node and npm\"), mdx(\"li\", {\n    \"parentName\": \"ul\"\n  }, \"Brew\"), mdx(\"li\", {\n    \"parentName\": \"ul\"\n  }, \"Postgres\")), mdx(\"p\", null, \"To use Phoenix and React, you need to install a few things on your computer. There are a surprising number of things that can go wrong with the installation, usually involving the installation of PostgreSQL.\"), mdx(\"h2\", null, \"Install Homebrew\"), mdx(\"p\", null, \"The first thing you should get is \", mdx(\"a\", {\n    \"href\": \"http://brew.sh/\",\n    \"parentName\": \"p\"\n  }, \"Homebrew\"), \". Homebrew allows you to run the command \", mdx(\"inlineCode\", {\n    \"parentName\": \"p\"\n  }, \"brew\"), \" to install just about anything on your Mac. Run the following command if you do not already have Homebrew installed. It might require you to install \", mdx(\"a\", {\n    \"href\": \"https://developer.apple.com/xcode/download/\",\n    \"parentName\": \"p\"\n  }, \"xcode\"), \" or some extra software. If it prompts you to do so, install that too:\"), mdx(\"pre\", null, mdx(\"code\", {\n    \"className\": \"language-bash\",\n    \"parentName\": \"pre\"\n  }, \"$ ruby -e \\\"$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)\\\"\\n\")), mdx(\"p\", null, \"You should check to make sure the installation ran properly by running the command \", mdx(\"inlineCode\", {\n    \"parentName\": \"p\"\n  }, \"brew help\"), \", which should pop up with some helper text. If you get an error, something went wrong and you should do some Googling to figure out what went wrong.\"), mdx(\"h2\", null, \"Install Node.js\"), mdx(\"p\", null, \"Now that you have Homebrew, it's pretty easy to install everything else. You will need \", mdx(\"a\", {\n    \"href\": \"https://nodejs.org/en/\",\n    \"parentName\": \"p\"\n  }, \"Node\"), \" to run your JavaScript server and to have access to the Node Package Manager (NPM), which you will use to install a variety of assets, including React and Redux.\"), mdx(\"p\", null, \"Run the following command to install Node:\"), mdx(\"pre\", null, mdx(\"code\", {\n    \"className\": \"language-bash\",\n    \"parentName\": \"pre\"\n  }, \"$ brew install node\\n\")), mdx(\"p\", null, \"Then, for good measure, check to make sure the installation was successful by running \", mdx(\"inlineCode\", {\n    \"parentName\": \"p\"\n  }, \"node -v\"), \", which will return the version of Node you are using. You should also check to make sure that NPM was installed by running \", mdx(\"inlineCode\", {\n    \"parentName\": \"p\"\n  }, \"npm -v\"), \".\"), mdx(\"h2\", null, \"Install Elixir\"), mdx(\"p\", null, \"We are assuming you're using a Mac, so the instructions below will be for a Mac installation. If you have a different machine, follow \", mdx(\"a\", {\n    \"href\": \"http://elixir-lang.org/install.html\",\n    \"parentName\": \"p\"\n  }, \"this link\"), \" to find instructions.\"), mdx(\"p\", null, \"If you're on a Mac, run:\"), mdx(\"pre\", null, mdx(\"code\", {\n    \"className\": \"language-bash\",\n    \"parentName\": \"pre\"\n  }, \"$ brew install elixir\\n\")), mdx(\"p\", null, \"And you're done. To ensure the installation went smoothly, run \", mdx(\"inlineCode\", {\n    \"parentName\": \"p\"\n  }, \"iex\"), \" to see if the interactive Elixir shell worked.\"), mdx(\"p\", null, \"If it did, and this is your first installation of Elixir, you will need to install the \", mdx(\"a\", {\n    \"href\": \"https://hex.pm/\",\n    \"parentName\": \"p\"\n  }, \"Hex package manager\"), \" (the Elixir equivalent to NPM). You can install it by running \", mdx(\"inlineCode\", {\n    \"parentName\": \"p\"\n  }, \"mix local.hex\")), mdx(\"h2\", null, \"Install Phoenix\"), mdx(\"p\", null, \"Now it's time to install Phoenix. Run the following command to install:\"), mdx(\"pre\", null, mdx(\"code\", {\n    \"className\": \"language-bash\",\n    \"parentName\": \"pre\"\n  }, \"$ mix archive.install https://github.com/phoenixframework/archives/raw/master/phoenix_new.ez\\n\")), mdx(\"h2\", null, \"Install PostgreSQL\"), mdx(\"p\", null, \"We will use PostgreSQL (often referred to as \\\"Postgres\\\") as our default database. A lot of things can go wrong here, so you might have to do some debugging to make sure you can get Posgres to work on your machine.\"), mdx(\"p\", null, \"Install Postgres by running the command:\"), mdx(\"pre\", null, mdx(\"code\", {\n    \"className\": \"language-bash\",\n    \"parentName\": \"pre\"\n  }, \"$ brew install postgresql\\n\")), mdx(\"p\", null, \"Postgres is now installed on your machine, but it is not running. You'll want to start Postgres at login, so run the following two commands to both set Postgres to launch at login and launch now:\"), mdx(\"pre\", null, mdx(\"code\", {\n    \"className\": \"language-bash\",\n    \"parentName\": \"pre\"\n  }, \"$ ln -sfv /usr/local/opt/postgresql/*.plist ~/Library/LaunchAgents\\n$ launchctl load ~/Library/LaunchAgents/homebrew.mxcl.postgresql.plist\\n\")), mdx(\"p\", null, \"To make sure everything installed properly, run the command \", mdx(\"inlineCode\", {\n    \"parentName\": \"p\"\n  }, \"which psql\"), \", which should return \", mdx(\"inlineCode\", {\n    \"parentName\": \"p\"\n  }, \"/usr/local/bin/psql\"), \". If it does not, something went wrong and you're in for some debugging.\"), mdx(\"p\", null, \"Now you need to create a default database, which should be the same as your username. If you do not know your username, you can find it by running the command \", mdx(\"inlineCode\", {\n    \"parentName\": \"p\"\n  }, \"whoami\"), \". Create the database with the following command, with your username in place of \", mdx(\"inlineCode\", {\n    \"parentName\": \"p\"\n  }, \"<username>\"), \":\"), mdx(\"pre\", null, mdx(\"code\", {\n    \"className\": \"language-bash\",\n    \"parentName\": \"pre\"\n  }, \"$ createdb `<username>`\\n\")), mdx(\"p\", null, \"Then run \", mdx(\"inlineCode\", {\n    \"parentName\": \"p\"\n  }, \"psql\"), \" to make sure the database was created properly. If you enter the Postgres shell, you're in business!\"), mdx(\"h2\", null, \"Postgres errors\"), mdx(\"p\", null, \"If you already have a previous version of Postgres installed, you will probably run into some problems.\"), mdx(\"pre\", null, mdx(\"code\", {\n    \"className\": \"language-bash\",\n    \"parentName\": \"pre\"\n  }, \"$ pg_ctl -D /usr/local/var/postgres -l logfile start\\n\")), mdx(\"p\", null, \"Another potential problem that comes up regularly is the lack of a \\\"role\\\". If you get the following error, you will need to configure a role:\"), mdx(\"pre\", null, mdx(\"code\", {\n    \"className\": \"language-bash\",\n    \"parentName\": \"pre\"\n  }, \"** (Mix) The database for Firestorm.Repo couldnt be created, reason given: psql: FATAL:  role \\\"postgres\\\" does not exist\\n\")), mdx(\"p\", null, \"You can configure a role by entering the \", mdx(\"inlineCode\", {\n    \"parentName\": \"p\"\n  }, \"psql\"), \" shell and creating the role. Run the following command:\"), mdx(\"pre\", null, mdx(\"code\", {\n    \"className\": \"language-bash\",\n    \"parentName\": \"pre\"\n  }, \"$ psql postgres\\n\")), mdx(\"p\", null, \"This will bring up a new shell that gives you the ability to run commands. You should enter the following to create the new role (note that \", mdx(\"inlineCode\", {\n    \"parentName\": \"p\"\n  }, \"postgres=#\"), \" is the prompt and should not be entered):\"), mdx(\"pre\", null, mdx(\"code\", {\n    \"className\": \"language-bash\",\n    \"parentName\": \"pre\"\n  }, \"postgres=# CREATE ROLE postgres LOGIN CREATEDB;\\n\")), mdx(\"p\", null, \"You should receive \", mdx(\"inlineCode\", {\n    \"parentName\": \"p\"\n  }, \"CREATE ROLE\"), \" as the response. Then exit the shell with \", mdx(\"inlineCode\", {\n    \"parentName\": \"p\"\n  }, \"\\\\q\"), \" and you should be in business!\"), mdx(\"p\", null, \"If you're \", mdx(\"em\", {\n    \"parentName\": \"p\"\n  }, \"still\"), \" having issues, try restarting Postgres with the following commands.\"), mdx(\"pre\", null, mdx(\"code\", {\n    \"className\": \"language-bash\",\n    \"parentName\": \"pre\"\n  }, \"$ pg_ctl -D /usr/local/var/postgres stop -s -m fast\\n$ pg_ctl -D /usr/local/var/postgres -l /usr/local/var/postgres/server.log start\\n\")), mdx(\"p\", null, \"And if you still can't get it working, try Stackoverflow or a Google search.\"), mdx(\"h2\", null, \"Additional Installations\"), mdx(\"p\", null, \"You will also need a text editor of some sort. You can use \", mdx(\"a\", {\n    \"href\": \"https://www.sublimetext.com/\",\n    \"parentName\": \"p\"\n  }, \"Sublime Text 3\"), \", \", mdx(\"a\", {\n    \"href\": \"https://atom.io/\",\n    \"parentName\": \"p\"\n  }, \"Atom\"), \", or any other text editor you'd like (or if you're a ninja, you can use \", mdx(\"a\", {\n    \"href\": \"http://www.vim.org/\",\n    \"parentName\": \"p\"\n  }, \"vim\"), \"). Some people also prefer an IDE (integrated development environment) such as \", mdx(\"a\", {\n    \"href\": \"https://www.jetbrains.com/webstorm/\",\n    \"parentName\": \"p\"\n  }, \"Webstorm\"), \". At the end of the day, this is all a matter of preference and will make little difference.\"));\n}\n;\nMDXContent.isMDXComponent = true;","excerpt":"Installing Phoenix and React Install Phoenix Node and npm Brew Postgres To use Phoenix and React, you need to install a few things on your…","frontmatter":{"title":"Installing Phoenix and React","order":1,"active":true,"free":true,"tech":["phoenix","react"]}}},"pageContext":{"slug":"installing-phoenix-and-react","prevNode":{"frontmatter":{"title":"Introduction","active":true,"free":true,"order":0,"tech":null},"fields":{"slug":"introduction"}},"nextNode":{"frontmatter":{"title":"Directory Structure","active":true,"free":true,"order":2,"tech":["phoenix","react"]},"fields":{"slug":"directory-structure"}}}},"staticQueryHashes":["1723017916"]}