--- title: Local Setup description: "The guide for contributors (or curious developers) who want to run Twenty locally." image: /images/user-guide/fields/field.png --- Header ## Forutsetninger Før du kan installere og bruke Twenty, sørg for at du installerer følgende på datamaskinen din: - [Git](https://git-scm.com/book/en/v2/Getting-Started-Installing-Git) - [Node v24.5.0](https://nodejs.org/en/download) - [yarn v4](https://yarnpkg.com/getting-started/install) - [nvm](https://github.com/nvm-sh/nvm/blob/master/README.md) `npm` vil ikke fungere, du bør bruke `yarn` i stedet. Yarn leveres nå med Node.js, så du trenger ikke installere det separat. Du behøver bare å kjøre `corepack enable` for å aktivere Yarn hvis du ikke allerede har gjort det. 1. Installer WSL. Åpne PowerShell som Administrator og kjør: ```powershell wsl --install ``` Du skal nå se en melding om å starte datamaskinen på nytt. Hvis ikke, start den manuelt. Etter omstart vil et PowerShell-vindu åpnes og Ubuntu vil bli installert. Dette kan ta litt tid. Du vil se en melding om å opprette et brukernavn og passord for Ubuntu-installasjonen din. 2. Installer og konfigurer git ```bash sudo apt-get install git git config --global user.name "Your Name" git config --global user.email "youremail@domain.com" ``` 3. Installer nvm, node.js og yarn Bruk `nvm` for å installere korrekt `node` versjon. `.nvmrc` sikrer at alle bidragsytere bruker samme versjon. ```bash sudo apt-get install curl curl -o- https://raw.githubusercontent.com/nvm-sh/nvm/master/install.sh | bash ``` Lukk og åpne terminalen din igjen for å bruke nvm. Kjør så følgende kommandoer. ```bash nvm install # installs recommended node version nvm use # use recommended node version corepack enable ``` --- ## Trinn 1: Git Clone I terminalen din, kjør følgende kommando. Hvis du ikke allerede har satt opp SSH-nøkler, kan du lære hvordan du gjør det [her](https://docs.github.com/en/authentication/connecting-to-github-with-ssh/about-ssh). ```bash git clone git@github.com:twentyhq/twenty.git ``` ```bash git clone https://github.com/twentyhq/twenty.git ``` ## Trinn 2: Plasser deg i rotkatalogen ```bash cd twenty ``` Du bør kjøre alle kommandoene i de følgende trinnene fra prosjektets rotnivå. ## Trinn 3: Sett opp en PostgreSQL Database **Option 1 (preferred):** To provision your database locally: Use the following link to install Postgresql on your Linux machine: [Postgresql Installation](https://www.postgresql.org/download/linux/) ```bash psql postgres -c "CREATE DATABASE \"default\";" -c "CREATE DATABASE test;" ``` Note: You might need to add `sudo -u postgres` to the command before `psql` to avoid permission errors. ```` **Option 2:** If you have docker installed: ```bash make postgres-on-docker ``` ```` **Option 1 (preferred):** To provision your database locally with `brew`: ```` ```bash brew install postgresql@16 export PATH="/opt/homebrew/opt/postgresql@16/bin:$PATH" brew services start postgresql@16 psql postgres -c "CREATE DATABASE \"default\";" -c "CREATE DATABASE test;" ``` You can verify if the PostgreSQL server is running by executing: ```bash brew services list ``` The installer might not create the `postgres` user by default when installing via Homebrew on MacOS. Instead, it creates a PostgreSQL role that matches your macOS username (e.g., "john"). To check and create the `postgres` user if necessary, follow these steps: ```bash # Connect to PostgreSQL psql postgres or psql -U $(whoami) -d postgres ``` Once at the psql prompt (postgres=#), run: ```bash # List existing PostgreSQL roles \du ``` You'll see output similar to: ```bash Role name | Attributes | Member of -----------+-------------+----------- john | Superuser | {} ``` If you do not see a `postgres` role listed, proceed to the next step. Create the `postgres` role manually: ```bash CREATE ROLE postgres WITH SUPERUSER LOGIN; ``` This creates a superuser role named `postgres` with login access. **Option 2:** If you have docker installed: ```bash make postgres-on-docker ``` ```` All the following steps are to be run in the WSL terminal (within your virtual machine) ```` **Option 1:** To provision your Postgresql locally: Use the following link to install Postgresql on your Linux virtual machine: [Postgresql Installation](https://www.postgresql.org/download/linux/) ```bash psql postgres -c "CREATE DATABASE \"default\";" -c "CREATE DATABASE test;" ``` Note: You might need to add `sudo -u postgres` to the command before `psql` to avoid permission errors. **Option 2:** If you have docker installed: Running Docker on WSL adds an extra layer of complexity. Only use this option if you are comfortable with the extra steps involved, including turning on [Docker Desktop WSL2](https://docs.docker.com/desktop/wsl). ```bash make postgres-on-docker ``` ```` Du kan nå få tilgang til databasen på [localhost:5432](localhost:5432), med brukernavn `postgres` og passord `postgres` . ## Trinn 4: Sett opp en Redis Database (cache) Twenty krever et redis cache for å gi best mulig ytelse **Option 1:** To provision your Redis locally: Use the following link to install Redis on your Linux machine: [Redis Installation](https://redis.io/docs/latest/operate/oss_and_stack/install/install-redis/install-redis-on-linux/) ```` **Option 2:** If you have docker installed: ```bash make redis-on-docker ``` ```` **Option 1 (preferred):** To provision your Redis locally with `brew`: ```bash brew install redis ``` Start your redis server: ```brew services start redis``` ```` **Option 2:** If you have docker installed: ```bash make redis-on-docker ``` ```` **Option 1:** To provision your Redis locally: Use the following link to install Redis on your Linux virtual machine: [Redis Installation](https://redis.io/docs/latest/operate/oss_and_stack/install/install-redis/install-redis-on-linux/) ```` **Option 2:** If you have docker installed: ```bash make redis-on-docker ``` ```` Hvis du trenger en klient-GUI, anbefaler vi [redis insight](https://redis.io/insight/) (gratis versjon tilgjengelig) ## Trinn 5: Sett opp miljøvariabler Bruk miljøvariabler eller `.env` filer for å konfigurere prosjektet ditt. Mer info [her](https://docs.twenty.com/l/no/developers/self-hosting/setup) Kopier `.env.example` filene i `/front` og `/server`: ```bash cp ./packages/twenty-front/.env.example ./packages/twenty-front/.env cp ./packages/twenty-server/.env.example ./packages/twenty-server/.env ``` ## Trinn 6: Installere avhengigheter For å bygge Twenty serveren og sette inn noen data i databasen din, kjør følgende kommando: ```bash yarn ``` Vær klar over at `npm` eller `pnpm` ikke vil fungere ## Trinn 7: Kjøre prosjektet Avhengig av Linux-distribusjonen din, kan det hende at Redis-serveren startes automatisk. Hvis ikke, sjekk [Redis-installasjonsveiledningen](https://redis.io/docs/latest/operate/oss_and_stack/install/install-redis/) for distribusjonen din. Redis skal allerede være i gang. If not, run: ```bash brew services start redis ``` Avhengig av Linux-distribusjonen din, kan det hende at Redis-serveren startes automatisk. Hvis ikke, sjekk [Redis-installasjonsveiledningen](https://redis.io/docs/latest/operate/oss_and_stack/install/install-redis/) for distribusjonen din. Sett opp databasen din med følgende kommando: ```bash npx nx database:reset twenty-server ``` Start serveren, arbeideren og frontend-tjenestene: ```bash npx nx start twenty-server npx nx worker twenty-server npx nx start twenty-front ``` Alternativt kan du starte alle tjenestene på en gang: ```bash npx nx start ``` ## Steg 8: Bruk Twenty **Frontend** Twentys frontend kjører på [http://localhost:3001](http://localhost:3001). Du kan logge inn med standard demokonto: `tim@apple.dev` (passord: `tim@apple.dev`) **Backend** - Twenty-serveren vil være i gang på [http://localhost:3000](http://localhost:3000) - GraphQL API-en kan nås på [http://localhost:3000/graphql](http://localhost:3000/graphql) - REST API-en kan nås på [http://localhost:3000/rest](http://localhost:3000/rest) ## Feilsøking Hvis du støter på problemer, sjekk [Feilsøking](https://docs.twenty.com/l/no/developers/self-hosting/troubleshooting) for løsninger.