Project Setup

Avatar of Hemanta SundarayHemanta Sundaray

The chapters in this course contain code snippets that are self-contained. I highly recommend you type them by hand and run them rather than passively reading through the content. This will help you understand and retain the concepts far better.

You can create a Node.js project by following the steps below.

Creating a Project

Create a new directory and initialize a Node.js project:

Terminal
mkdir effect-scope
cd effect-scope
pnpm init

Installing Dependencies

Run the following command to install the required packages:

Terminal
pnpm add effect@4.0.0-beta.42
pnpm add -D typescript tsx @types/node

Configuring the Project

Add "type": "module" to your package.json to enable ES modules:

package.json
{
"name": "effect-scope",
"version": "1.0.0",
"description": "",
"main": "index.js",
"scripts": {
"test": "echo \"Error: no test specified\" && exit 1"
},
"keywords": [],
"author": "",
"license": "ISC",
"type": "module",
"packageManager": "pnpm@10.28.0",
"dependencies": {
"effect": "4.0.0-beta.42"
},
"devDependencies": {
"@types/node": "^25.5.0",
"tsx": "^4.21.0",
"typescript": "^6.0.2"
}
}

Create a tsconfig.json in the project root:

tsconfig.json
{
"compilerOptions": {
"target": "ES2022",
"module": "nodenext",
"moduleResolution": "nodenext",
"strict": true,
"skipLibCheck": true,
"forceConsistentCasingInFileNames": true,
"outDir": "./dist"
},
"include": ["*.ts"]
}

Creating a TypeScript File

Create a file named resource-leak-demo.ts in the project root. This is the file where we will write all of our code.

Running TypeScript Files

We use tsx to run TypeScript files directly without a separate compilation step. Every code snippet in this course is complete and runnable. To run the file, use:

Terminal
npx tsx resource-leak-demo.ts

Note that tsx does not perform type checking. To catch type errors, run npx tsc --noEmit separately.

Sign in to save progress

Stay in the loop

Get notified when new Effect Atom related content is published.