Let’s create a project and install the required dependencies.
Creating a Project
Create a new directory and initialize a Node.js project:
mkdir effect-schemacd effect-schemanpm init -yInstalling Dependencies
Run the following command to install the required packages:
npm install effect@4.0.0-beta.20npm install -D typescript tsx @types/nodeConfiguring the Project
Add "type": "module" to your package.json to enable ES modules:
{ "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:
{ "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:
npx tsx schema.tsNote that tsx does not perform type checking. To catch type errors, run npx tsc --noEmit separately.