Project Setup

Avatar of Hemanta SundarayHemanta Sundaray

Let’s create a project and install the required dependencies.

Creating a Project

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

Terminal
mkdir effect-schema
cd effect-schema
npm init -y

Installing Dependencies

Run the following command to install the required packages:

Terminal
npm install effect@4.0.0-beta.20
npm install -D typescript tsx @types/node

Configuring the Project

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

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

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"]
}

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 try any example, copy the code into a .ts file (e.g., schema.ts) and run it with:

Terminal
npx tsx schema.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 chapters are added and when this course is complete.