Quickstart

In this tutorial, we will guide you through the process of setting up a new Effect project from scratch using plain TypeScript 5.0 or newer.


Follow these steps to create a new Effect project for Node.js:

  1. As a first step, create a project directory and navigate into it:

    Terminal
    bash
    mkdir hello-effect
    cd hello-effect
    Terminal
    bash
    mkdir hello-effect
    cd hello-effect
  2. Next, initialize a TypeScript project using npm (make sure you have TypeScript 5.0 or newer):

    Terminal
    bash
    npm init -y
    npm install typescript --save-dev
    Terminal
    bash
    npm init -y
    npm install typescript --save-dev

    This creates a package.json file with an initial setup for your TypeScript project.

  3. Now, initialize TypeScript:

    Terminal
    bash
    npx tsc --init
    Terminal
    bash
    npx tsc --init

    When running this command, it will generate a tsconfig.json file that contains configuration options for TypeScript. One of the most important options to consider is the strict flag.

    Make sure to open the tsconfig.json file and verify that the value of the strict option is set to true.

    tsconfig.json
    json
    {
    "compilerOptions": {
    "strict": true
    }
    }
    tsconfig.json
    json
    {
    "compilerOptions": {
    "strict": true
    }
    }
  4. Then, install the necessary package as dependency:

    Terminal
    bash
    npm install effect
    Terminal
    bash
    npm install effect

    This package will provide the foundational functionality for your Effect project.

Let's write and run a simple program to ensure that everything is set up correctly.

In your terminal, execute the following commands:

Terminal
bash
mkdir src
touch src/index.ts
Terminal
bash
mkdir src
touch src/index.ts

Open the index.ts file and add the following code:

src/index.ts
ts
import { Effect, Console } from "effect"
const program = Console.log("Hello, World!")
Effect.runSync(program)
src/index.ts
ts
import { Effect, Console } from "effect"
const program = Console.log("Hello, World!")
Effect.runSync(program)

Run the index.ts file. If you have ts-node installed, run the following command in the terminal:

Terminal
bash
ts-node src/index.ts
Terminal
bash
ts-node src/index.ts

You should see the message "Hello, World!" printed. This confirms that the program is working correctly.