Getting started
Follow the steps below to get a local development environment up and running.
Prerequisites
Before you can start developing, you need to install the following tools:
Are you using Windows?
If you're running Windows, it's highly recommended to first install WSL. This sets up a Linux environment on your Windows machine and simplifies development.
When you have WSL installed, you can open a WSL terminal and follow the instructions below as if you were using a Linux distribution.
Install Node.JS.
Click on the link above and install Node.js LTS. Using nvm is recommended. When the installation is complete, open a terminal and verify that Node.js is installed by running the following command:
bashnode -v
It should output the version of Node.js you installed (your version may be different).
bashv20.17.0
Install pnpm.
Now, install the package manager pnpm. Installing pnpm using Corepack is strongly recommended. When the installation is complete, open a terminal and ensure pnpm works as expected by running the following command:
bashpnpm -v
It should output the version of pnpm you installed (your version may be different).
bash9.7.1
Install Docker Desktop.
Finally, install Docker by installing the graphical Docker interface Docker Desktop. This is not strictly required for development, but it simplifies setting up a development database. When the installation is complete, open a terminal and verify that Docker is installed by running the following command:
bashdocker -v
It should output the version of Docker you installed (your version may be different).
bashDocker version 20.10.17, build 100c701
Setting up the project
Clone the repo into
dsek-web
and change into the directory.bashgit clone https://github.com/Dsek-LTH/web.git dsek-web && cd dsek-web
Install all dependencies using
pnpm
.bashpnpm install
Setup your local development database. Having problems?
bashsh ./dev/setup_db.sh
Start the development server.
bashpnpm dev
Congratulations! You should now be able to visit your application on http://localhost:5173.
Troubleshooting
Issues commonly occur when setting up the local development database. Usually, this shows up either as errors when running sh ./dev/setup_db.sh
or as simply not seeing any data when the development server starts. Here are some steps you can try to fix the problem:
Begin by deleting the local database. Open Docker Desktop and delete
dsek-db
(or use the command below).bashdocker rm --force dsek-db
If you noticed permission errors while running
sh ./dev/setup_db.sh
, try running the script usingsudo
.bashsudo sh ./dev/setup_db.sh
Finally, you can always try to run the commands in the
./dev/setup_db.sh
script manually. This makes it easier to troubleshoot what's going on. Open a terminal and run the commands below one-by-one.INFO
Some commands span multiple lines! Backslashes
\
are used to break a command into multiple lines. These commands must be copied in their entirety instead of line-by-line.sh#!/bin/bash docker run \ --name dsek-db \ --publish 5432:5432 \ --env POSTGRES_USER=postgres \ --env POSTGRES_PASSWORD=postgres \ --env POSTGRES_DB=dsek \ --detach \ postgres:14-alpine echo "\nWaiting for database to start..." until docker exec dsek-db pg_isready do sleep 0.5; done # Sometimes the database is not ready yet even though pg_isready returns true sleep 0.5; # Setup migrations for prisma and seed database pnpm migrate pnpm seed