How to get 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 Linux normally.
Install Node.js.
Using nvm to install Node.js is strongly recommended.
The installation steps are provided below for reference, but for up-to-date instructions, visit the link above. Open a terminal and run the following commands:
bash# installs nvm (Node Version Manager) curl -o- https://raw.githubusercontent.com/nvm-sh/nvm/v0.40.0/install.sh | bash # download and install Node.js (you may need to restart the terminal) nvm install 20 # verifies the right Node.js version is in the environment node -v # should print `v20.18.0` # verifies the right npm version is in the environment npm -v # should print `10.8.2`
Install pnpm.
Now, install the package manager pnpm. Installing pnpm using Corepack is strongly recommended.
bashcorepack enable pnpm
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
. Having problems?bashpnpm install
Setup your local development database. Having problems?
bash./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
Node.js permissions issues
If you encounter permission issues when running the pnpm install
command, you may have installed Node.js using sudo
. This can cause permission issues when installing packages. To fix this, we recommend uninstalling Node.js completely and reinstalling it without sudo
using nvm
.
Database setup issues
Issues commonly occur when setting up the local development database. Usually, this shows up either as errors when running ./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
./dev/setup_db.sh
, try running the script usingsudo
.bashsudo ./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 compose up -d 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