Created by Github action --------- Co-authored-by: github-actions <github-actions@twenty.com>
330 lines
9.1 KiB
Plaintext
330 lines
9.1 KiB
Plaintext
---
|
|
title: Configuración Local
|
|
description: "La guía para los colaboradores (o desarrolladores curiosos) que quieren ejecutar Twenty localmente."
|
|
image: /images/user-guide/fields/field.png
|
|
---
|
|
|
|
<Frame>
|
|
<img src="/images/user-guide/fields/field.png" alt="Header" />
|
|
</Frame>
|
|
|
|
## Prerrequisitos
|
|
|
|
<Tabs>
|
|
<Tab title="Linux and MacOS">
|
|
|
|
Antes de que puedas instalar y usar Twenty, asegúrate de instalar lo siguiente en tu computadora:
|
|
|
|
- [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)
|
|
|
|
<Warning>
|
|
`npm` no funcionará, deberías usar `yarn` en su lugar. Yarn ahora se envía con Node.js, por lo que no necesitas instalarlo por separado.
|
|
Solo tienes que ejecutar `corepack enable` para habilitar Yarn si aún no lo has hecho.
|
|
</Warning>
|
|
|
|
</Tab>
|
|
|
|
<Tab title="Windows (WSL)">
|
|
|
|
1. Instalar WSL
|
|
Abre PowerShell como Administrador y ejecuta:
|
|
|
|
```powershell
|
|
wsl --install
|
|
```
|
|
|
|
Ahora deberías ver un aviso para reiniciar tu computadora. Si no, reiníciala manualmente.
|
|
|
|
Al reiniciar, se abrirá una ventana de PowerShell e instalará Ubuntu. Esto puede tomar algo de tiempo.
|
|
Verás un aviso para crear un nombre de usuario y contraseña para tu instalación de Ubuntu.
|
|
|
|
2. Instalar y configurar git
|
|
|
|
```bash
|
|
sudo apt-get install git
|
|
|
|
git config --global user.name "Your Name"
|
|
|
|
git config --global user.email "youremail@domain.com"
|
|
```
|
|
|
|
3. Instalar nvm, node.js y yarn
|
|
|
|
<Warning>
|
|
Usa `nvm` para instalar la versión correcta de `node`. El `.nvmrc` asegura que todos los colaboradores usen la misma versión.
|
|
</Warning>
|
|
|
|
```bash
|
|
sudo apt-get install curl
|
|
|
|
curl -o- https://raw.githubusercontent.com/nvm-sh/nvm/master/install.sh | bash
|
|
```
|
|
|
|
Cierra y vuelve a abrir tu terminal para usar nvm. Luego ejecuta los siguientes comandos.
|
|
|
|
```bash
|
|
|
|
nvm install # installs recommended node version
|
|
|
|
nvm use # use recommended node version
|
|
|
|
corepack enable
|
|
```
|
|
|
|
</Tab>
|
|
</Tabs>
|
|
|
|
---
|
|
|
|
## Paso 1: Clonar con Git
|
|
|
|
En tu terminal, ejecuta el siguiente comando.
|
|
|
|
<Tabs>
|
|
<Tab title="SSH (Recommended)">
|
|
Si aún no has configurado claves SSH, puedes aprender cómo hacerlo [aquí](https://docs.github.com/en/authentication/connecting-to-github-with-ssh/about-ssh).
|
|
```bash
|
|
git clone git@github.com:twentyhq/twenty.git
|
|
```
|
|
</Tab>
|
|
<Tab title="HTTPS">
|
|
|
|
```bash
|
|
git clone https://github.com/twentyhq/twenty.git
|
|
```
|
|
|
|
</Tab>
|
|
</Tabs>
|
|
|
|
## Paso 2: Ubícate en la raíz
|
|
|
|
```bash
|
|
cd twenty
|
|
```
|
|
|
|
Debes ejecutar todos los comandos de los siguientes pasos desde la raíz del proyecto.
|
|
|
|
## Paso 3: Configurar una Base de Datos PostgreSQL
|
|
|
|
<Tabs>
|
|
<Tab title="Linux">
|
|
**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
|
|
```
|
|
````
|
|
|
|
</Tab>
|
|
<Tab title="Mac OS">
|
|
**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
|
|
```
|
|
````
|
|
|
|
</Tab>
|
|
<Tab title="Windows (WSL)">
|
|
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
|
|
```
|
|
````
|
|
|
|
</Tab>
|
|
</Tabs>
|
|
|
|
Ahora puedes acceder a la base de datos en [localhost:5432](localhost:5432), con usuario `postgres` y contraseña `postgres`.
|
|
|
|
## Paso 4: Configurar una Base de Datos Redis (cache)
|
|
|
|
Twenty requiere un caché de redis para proporcionar el mejor rendimiento
|
|
|
|
<Tabs>
|
|
<Tab title="Linux">
|
|
**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
|
|
```
|
|
````
|
|
|
|
</Tab>
|
|
<Tab title="Mac OS">
|
|
**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
|
|
```
|
|
````
|
|
|
|
</Tab>
|
|
<Tab title="Windows (WSL)">
|
|
**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
|
|
```
|
|
````
|
|
|
|
</Tab>
|
|
</Tabs>
|
|
|
|
If you need a Client GUI, we recommend [redis insight](https://redis.io/insight/) (free version available)
|
|
|
|
## Paso 5: Configurar las variables de entorno
|
|
|
|
Usa variables de entorno o archivos `.env` para configurar tu proyecto. Más información [aquí](https://docs.twenty.com/l/es/developers/self-hosting/setup)
|
|
|
|
Copia los archivos `.env.example` en `/front` y `/server`:
|
|
|
|
```bash
|
|
cp ./packages/twenty-front/.env.example ./packages/twenty-front/.env
|
|
cp ./packages/twenty-server/.env.example ./packages/twenty-server/.env
|
|
```
|
|
|
|
## Paso 6: Instalación de dependencias
|
|
|
|
Para compilar el servidor de Twenty e ingresar algunos datos en tu base de datos, ejecuta el siguiente comando:
|
|
|
|
```bash
|
|
yarn
|
|
```
|
|
|
|
Ten en cuenta que `npm` o `pnpm` no funcionarán
|
|
|
|
## Paso 7: Ejecutar el proyecto
|
|
|
|
<Tabs>
|
|
<Tab title="Linux">
|
|
Dependiendo de tu distribución de Linux, el servidor Redis podría iniciarse automáticamente.
|
|
Si no es así, consulte la [guía de instalación de Redis](https://redis.io/docs/latest/operate/oss_and_stack/install/install-redis/) para su distribución.
|
|
</Tab>
|
|
<Tab title="Mac OS">
|
|
Redis ya debería estar funcionando. If not, run:
|
|
```bash
|
|
brew services start redis
|
|
```
|
|
</Tab>
|
|
<Tab title="Windows (WSL)">
|
|
Dependiendo de tu distribución de Linux, el servidor Redis podría iniciarse automáticamente.
|
|
Si no es así, consulte la [guía de instalación de Redis](https://redis.io/docs/latest/operate/oss_and_stack/install/install-redis/) para su distribución.
|
|
</Tab>
|
|
</Tabs>
|
|
|
|
Configure su base de datos con el siguiente comando:
|
|
|
|
```bash
|
|
npx nx database:reset twenty-server
|
|
```
|
|
|
|
Inicie el servidor, el trabajador y los servicios frontend:
|
|
|
|
```bash
|
|
npx nx start twenty-server
|
|
npx nx worker twenty-server
|
|
npx nx start twenty-front
|
|
```
|
|
|
|
Alternativamente, puede iniciar todos los servicios a la vez:
|
|
|
|
```bash
|
|
npx nx start
|
|
```
|
|
|
|
## Paso 8: Use Twenty
|
|
|
|
**Frontend**
|
|
|
|
El frontend de Twenty estará ejecutándose en [http://localhost:3001](http://localhost:3001).
|
|
Puede iniciar sesión usando la cuenta demo por defecto: `tim@apple.dev` (contraseña: `tim@apple.dev`)
|
|
|
|
**Backend**
|
|
|
|
- El servidor de Twenty estará operativo en [http://localhost:3000](http://localhost:3000)
|
|
- La API GraphQL puede ser accedida en [http://localhost:3000/graphql](http://localhost:3000/graphql)
|
|
- La API REST puede ser alcanzada en [http://localhost:3000/rest](http://localhost:3000/rest)
|
|
|
|
## Solución de Problemas
|
|
|
|
Si encuentra algún problema, consulte [Solución de Problemas](https://docs.twenty.com/l/es/developers/self-hosting/troubleshooting) para soluciones. |