--- title: Локальна установка description: "Посібник для учасників проекту (або цікавих розробників), які хочуть запустити Twenty локально." image: Неможливо перекласти --- Header ## Передумови Перед інсталяцією та використанням Twenty переконайтеся, що встановлено наступне на вашому комп'ютері: - [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` не працюватиме, слід використовувати `yarn`. Yarn тепер постачається разом з Node.js, тому вам не потрібно встановлювати його окремо. Вам потрібно виконати `corepack enable`, щоб увімкнути Yarn, якщо ви ще цього не зробили. 1. Install WSL Open PowerShell as Administrator and run: ```powershell wsl --install ``` Тепер ви маєте побачити запит на перезапуск комп'ютера. Якщо ні, перезапустіть вручну. Після перезапуску вікно powershell відкриється і встановить Ubuntu. Це може забрати певний час. Ви побачите запит на створення імені користувача та пароля для вашої установки Ubuntu. 2. Встановлення та налаштування git ```bash sudo apt-get install git git config --global user.name "Your Name" git config --global user.email "youremail@domain.com" ``` 3. Встановлення nvm, node.js та yarn Використовуйте `nvm`, щоб встановити правильну версію `node`. `.nvmrc` забезпечує, що всі учасники використовують одну й ту ж версію. ```bash sudo apt-get install curl curl -o- https://raw.githubusercontent.com/nvm-sh/nvm/master/install.sh | bash ``` Закрийте та відкрийте знову свій термінал, щоб використовувати nvm. Тоді виконайте наступні команди. ```bash nvm install # installs recommended node version nvm use # use recommended node version corepack enable ``` --- ## Крок 1: Клонування Git В своєму терміналі виконайте наступну команду. Якщо ви ще не налаштовували SSH-ключі, ви можете дізнатися, як це зробити, [тут](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 ``` ## Крок 2: Перемістіть себе до кореня ```bash cd twenty ``` Усі команди з наступних кроків слід виконувати з кореня проекту. ## Крок 3: Налаштування бази даних PostgreSQL **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 ``` ```` Тепер ви можете отримати доступ до бази даних за адресою [localhost:5432](localhost:5432), з користувачем `postgres` і паролем `postgres`. ## Крок 4: Налаштування бази даних Redis (кешу) Twenty вимагає кешу redis для забезпечення найкращої продуктивності **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 ``` ```` Якщо вам необхідний клієнтський GUI, ми рекомендуємо [redis insight](https://redis.io/insight/) (доступна безкоштовна версія) ## Step 5: Setup environment variables Use environment variables or `.env` files to configure your project. Більше інформації [тут](https://docs.twenty.com/l/uk/developers/self-hosting/setup) Скопіюйте файли `.env.example` у `/front` та `/server`: ```bash cp ./packages/twenty-front/.env.example ./packages/twenty-front/.env cp ./packages/twenty-server/.env.example ./packages/twenty-server/.env ``` ## Крок 6: Встановлення залежностей Щоб побудувати сервер Twenty і додати деякі дані в вашу базу даних, виконайте наступну команду: ```bash yarn ``` Зверніть увагу, що `npm` або `pnpm` не працюватимуть ## Крок 7: Запуск проекту Залежно від вашої дистрибуції Linux, сервер Redis може бути запущений автоматично. Якщо ні, перевірте [керівництво по встановленню Redis](https://redis.io/docs/latest/operate/oss_and_stack/install/install-redis/) для вашої дистрибуції. Redis повинен бути вже запущений. If not, run: ```bash brew services start redis ``` Залежно від вашої дистрибуції Linux, сервер Redis може бути запущений автоматично. Якщо ні, перевірте [керівництво по встановленню Redis](https://redis.io/docs/latest/operate/oss_and_stack/install/install-redis/) для вашої дистрибуції. Налаштуйте вашу базу даних за допомогою наступної команди: ```bash npx nx database:reset twenty-server ``` Запустіть сервер, worker і frontend сервіси: ```bash npx nx start twenty-server npx nx worker twenty-server npx nx start twenty-front ``` Альтернативно, ви можете запустити всі сервіси одночасно: ```bash npx nx start ``` ## Крок 8: Використання Twenty **Frontend** Frontend Twenty працюватиме на [http://localhost:3001](http://localhost:3001). Ви можете увійти, використовуючи стандартний демо-акаунт: `tim@apple.dev` (пароль: `tim@apple.dev`) **Backend** - Сервер Twenty буде запущений на [http://localhost:3000](http://localhost:3000) - До GraphQL API можна отримати доступ за адресою [http://localhost:3000/graphql](http://localhost:3000/graphql) - REST API доступний за адресою [http://localhost:3000/rest](http://localhost:3000/rest) ## Усунення несправностей Якщо виникнуть проблеми, перегляньте [Усунення несправностей](https://docs.twenty.com/l/uk/developers/self-hosting/troubleshooting) для отримання вирішення.