| title | Set Up a New Effect Project | |||||||
|---|---|---|---|---|---|---|---|---|
| id | setup-new-project | |||||||
| skillLevel | beginner | |||||||
| applicationPatternId | project-setup--execution | |||||||
| summary | Initialize a new Node.js project with the necessary TypeScript configuration and Effect dependencies to start building. | |||||||
| tags |
|
|||||||
| rule |
|
|||||||
| related |
|
|||||||
| author | Paul Philp | |||||||
| lessonOrder | 17 |
To start a new Effect project, initialize a standard Node.js project, add
effect and typescript as dependencies, and create a tsconfig.json file
with strict mode enabled.
A proper setup is crucial for leveraging Effect's powerful type-safety
features. Using TypeScript's strict mode is non-negotiable.
// 1. Init project (e.g., `npm init -y`)
// 2. Install deps (e.g., `npm install effect`, `npm install -D typescript tsx`)
// 3. Create tsconfig.json with `"strict": true`
// 4. Create src/index.ts
import { Effect } from "effect";
const program = Effect.log("Hello, World!");
Effect.runSync(program);
// 5. Run the program (e.g., `npx tsx src/index.ts`)Explanation:
This setup ensures you have TypeScript and Effect ready to go, with strict
type-checking for maximum safety and correctness.
Avoid disabling strict mode in your tsconfig.json. Running with
"strict": false will cause you to lose many of the type-safety guarantees
that make Effect so powerful.