Skip to content

Windows Setup

Rey Dekker edited this page Oct 1, 2020 · 4 revisions

Installation for Windows Users

After finishing this doc you will have VSCode, Node.js, Git, Nodemon and Posgres installed on your machine.

VSCode

  1. Vist VSCode to download VSCode.
  2. Launch the installer and follow the onscreen prompts.
  3. When you reach the section for Additional tasks, make sure every box is checked.
  4. Click install and continue to follow and onscreen prompts.

Once you are done, you can open up a terminaland type code to open VSCode. This may or may not require a restart first.

Node.js - Version 10.x

  1. Visit Node.js and download and run the Windows installer. No need to check "Automatically install the necessary modules".
  2. You can check your current Node.js version with by running node -v in your command line

Git

  1. Visit Git to download and install Git. This will include the Git Bash CLI, which is our preferred terminalfor Windows.

  2. Follow the onscreen instructions.

    • Choose the default values for each prompt...
    • EXCEPT when it asks you to Choose the default editor used by Git...
      • Click the drop down and choose the VSCode option
      • Do NOT choose the "VSCode Insiders" option.
  3. Continue choosing the default options to finish the installation.

  4. You can check your current version of Git with by running git --version in your command line

Set up the Git Config

The final step here is to add your email and name to the Git config. This will allow you to commit and push things to GitHub. Make sure to include the space after .email and .name, and always remember to close your quotes ' ' and " ".

  1. Close and reopen your command line and run the following:
  2. Type git config --global user.email 'Your email here in single quotes'.
  3. Type git config --global user.name 'Your Name In Single Quotes'.
  4. Type git config --global core.editor 'code --wait'.

Verify that everything is set correctly by running git config --global --list

Nodemon

Nodemon is a tool that is used to restart the server when changes are made in your server code. To install, run npm i -g nodemon in your CLI. Run the command nodemon -v to confirm proper installation of Nodemon.

PostgreSQL

  1. Go to PostgreSQL's [Windows installers]https://www.postgresql.org/download/windows/, and click on "Download the installer". You will be redirected to EDB to download the installer.
  2. Download the 11.9 version for Windows.
  3. During the setup, for Select Components, uncheck Stack Builder
  4. Complete all other steps as directed
  • Make note of the password for the postgres user that is being created during the process

psql

Verify psql is available in the command line by running psql -V.

If you get an error saying that the command is not recognized, then you'll need to add a pointer to the PostgreSQL bin to your PATH variable. To do so, follow the steps below:

  1. Search for "Environment Variables" in the Windows Search bar
  2. Click on the "Edit the system environment variables" suggestion
  3. This will open System Properties > Advanced; click on the Environment Variables... in the bottom right corner
  4. Under System Variables (the bottom half), find the Path variable; click Edit...
  5. Add C:\Program Files\PostgreSQL\11\bin as a new environment variable
  6. Restart your terminal. The update is successful if running psql -V returns psql (PostgreSQL) 11.9

Postgres User Setup

Verifying Installation And Setting A Password

  • You should be able to run the command psql -U postgres. You will be asked for a password - this is the password you created during the Postgres installation. This will log you into the psql CLI as the user postgres.

  • You should now have a prompt that looks like postgres=#. You can run SQL commands from here, which must end in semicolons.

  • If you were not prompted for a default user or password, we will set one using psql. If you type \du, you can get a list of users associated with PostgreSQL. You should see a single user, postgres. You will need to set up a new role for your machine's default user. This is the username that appears at the beginning of your CLI, and when you log into your machine.

  • In your SQL shell, type the following: CREATE ROLE your-username-here WITH LOGIN PASSWORD 'your-password-here';, replacing "your-password-here" with whatever you want it to be. Remember that your password must be wrapped in quotes. The username should not be wrapped in quotes. Don't forget the semicolon.

  • If successful, you will receive the feedback CREATE ROLE.

  • Now we need to grant that user administrative control. In your SQL shell, type the following: ALTER ROLE your-username-here WITH superuser;, replacing "your-username-here" with the username you created a role for in the previous step.

  • If successful, you will receive the feedback ALTER ROLE.

  • Next, we need to create a default database for your new user and assign ownership of it to your new account. In the SQL shell, type the following: CREATE DATABASE scproject;. Must be scproject. On success, you will receive the feedback CREATE DATABASE.

    • Note: You might get a WARNING: could not flush dirty data: Function not implemented warning many times when you run this command. This is okay! Let the command keep running, and you should eventually see success.
  • To change the owner of your database from the postgres user to your user, type the folliwing: ALTER DATABASE scproject OWNER TO your-username-here;, replacing "your-username-here" with your username. On success, you will receive the feedback ALTER DATABASE.

  • Close your SQL shell with \q or ctrl-D. Type psql again and your SQL shell should now open as your default user. Hooray!

Running the PostgreSQL Server

To start, stop or restart the PostgreSQL server with the following commands:
Note that the path to your PostgreSQL installation may vary

  • Start: pg_ctl -D "C:\Program Files\PostgreSQL\11\data" start
  • Stop: pg_ctl -D "C:\Program Files\PostgreSQL\11\data" stop
  • Restart pg_ctl -D "C:\Program Files\PostgreSQL\11\data" restart

Next Step

Go ahead and install the database next.

Clone this wiki locally