--- title: Локальная настройка description: "Руководство для участников (или любопытных разработчиков), которые хотят запускать Twenty локально." image: /images/user-guide/fields/field.png --- 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. Установите WSL Откройте PowerShell от имени администратора и выполните: ```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 ``` ```` Если вам нужен графический интерфейс клиента, мы рекомендуем [redis insight](https://redis.io/insight/) (доступна бесплатная версия) ## Шаг 5: Настройка переменных окружения Используйте переменные окружения или файлы `.env` для настройки вашего проекта. Подробнее [здесь](https://docs.twenty.com/l/ru/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 ``` Запустите сервер, рабочую программу и сервисы фронтенда: ```bash npx nx start twenty-server npx nx worker twenty-server npx nx start twenty-front ``` В качестве альтернативы, вы можете запустить все сервисы сразу: ```bash npx nx start ``` ## Шаг 8: Использовать Twenty **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/ru/developers/self-hosting/troubleshooting) для получения решений.