Files
twenty/docs/docs/contributor/local-setup/yarn-setup.mdx
T
Nimra Ahmed ae32a2da3b Revised contributing.md, edited docs (#1951)
* Added Overview page

* Revised Getting Started page

* Minor revision

* Edited readme, minor modifications to docs

* Removed sweep.yaml, .devcontainer, .ergomake

* Moved security.md to .github, added contributing.md

* changes as per code review

* updated contributing.md

* fixed broken links & added missing links in doc, improved structure

* fixed link in wsl setup

* fixed server link, added https cloning in yarn-setup
2023-10-10 12:33:17 +02:00

151 lines
4.1 KiB
Plaintext

---
title: Yarn Setup
sidebar_position: 1
sidebar_custom_props:
icon: TbScript
---
import Tabs from '@theme/Tabs';
import TabItem from '@theme/TabItem';
In this document, you'll learn how to install the project using yarn. We recommend this method since it's the easiest way to get started but you can also run the project with [Docker](/contributor/local-setup/docker-setup) or [WSL2](/contributor/local-setup/wsl-setup).
> **Note:** `npm` currently does not support local packages satisfactorily. We strongly recommend using `yarn` instead.
## Prerequisites
Before you can install and use Twenty, make sure you install the following on your computer:
- [Git](https://git-scm.com/book/en/v2/Getting-Started-Installing-Git)
- [Node](https://nodejs.org/en/download)
- [yarn](https://classic.yarnpkg.com/lang/en/docs/install/)
- [nvm](https://github.com/nvm-sh/nvm/blob/master/README.md)
---
## Step #1: Git Clone
In your terminal, run the following command.
We recommend using SSH for this step. If you already haven't set up SSH keys, please do so first. You can learn more about it [here](https://docs.github.com/en/authentication/connecting-to-github-with-ssh/about-ssh).
<Tabs>
<TabItem value="ssh" label="SSH (Recommended)" default>
```bash
git clone git@github.com:twentyhq/twenty.git
```
</TabItem>
<TabItem value="https" label="HTTPS (Not Recommended)" >
```bash
git clone https://github.com/twentyhq/twenty.git
```
</TabItem>
</Tabs>
## Step #2: Set up PostgreSQL Database
You need to have a PostgreSQL database available to be able to use Twenty. If you already have one available, you can skip this step.
If you don't, you can provision one through `docker`. With docker running, use the following commands:
<Tabs>
<TabItem value="docker" label="Docker" default>
```bash
cd twenty
make provision-postgres
```
This will create a Docker container, exposing a PostgresSQL instance at [http://localhost:5432](http://localhost:5432).
This instance contains two databases: `default` and `test`
You can access them using `twenty` postgres user (password: `twenty`)
</TabItem>
<TabItem value="linux-wsl" label="Linux / Windows WSL">
To install PostgresSQL on WSL2, use the following commands:
```bash
sudo apt update
sudo apt install postgresql postgresql-contrib
```
Start postgresql service and connect to the database using default `postgres` user:
```bash
sudo service postgresql start
sudo -u postgres psql
```
Create two databases:
```sql
CREATE DATABASE "default";
CREATE DATABASE "test";
```
Create a user `twenty` with password `twenty`:
```sql
CREATE USER twenty PASSWORD 'twenty';
ALTER USER twenty CREATEDB;
```
Create `metadata` schema:
```sql
CREATE SCHEMA IF NOT EXISTS "metadata";
GRANT ALL ON SCHEMA metadata TO twenty;
```
Activate `uuid-ossp` extension:
```sql
CREATE EXTENSION IF NOT EXISTS "uuid-ossp";
```
</TabItem>
</Tabs>
## Step #3: Setup env variables
Twenty requires a few environment variables to be set. Locally, we recommend setting them through a `.env` file.
To do so, make copies of the `.env.example` files in `/front` and `/server`:
```bash
cp ./front/.env.example ./front/.env
cp ./server/.env.example ./server/.env
```
## Step #4: Server setup
> **Note:** We recommend that you use `nvm` to install the correct `node` version. We have added a `server/.nvmrc` to ensure all contributors use the same version.
To build Twenty server and seed some data into your database, run the following commands:
```bash
cd server
nvm install #recommended
nvm use #recommended
yarn
yarn prisma:reset
yarn start:dev
```
Twenty's server will be up and running at [http://localhost:3000/graphql](http://localhost:3000/graphql).
## Step #5: Frontend setup
> **Note:** For the frontend setup, too, we recommend using `nvm` to install the right node version.
To set up the frontend, run the following commands in your terminal:
```bash
cd ../front
nvm install #recommended
nvm use #recommended
yarn
yarn start
```
Twenty's frontend will be running at [http://localhost:3001](http://localhost:3001). Simply login using our seeded demo account: `tim@apple.dev` to start using Twenty.