Coders In Hoods
  • Courses
  • Roles
  • Blog
  • Setup

Coders In Hoods AI Academy

Every course is free. Sign in to start, and your progress, quiz scores and bookmarks follow you.

AI Academy

  • Courses
  • Paths
  • Setup guides
  • How we teach

Role roadmaps

  • AI Engineer
  • Forward Deployed Engineer
  • Machine Learning Engineer
  • All roles

Coders In Hoods

  • The agency
  • Coaching for teams
  • Blog
  • LinkedIn
  • X (Twitter)

Contact

codersinhoods@gmail.com

© Coders In Hoods · since 2019

Setup guides

Setup guide · Essentials

Node.js, pnpm and TypeScript

A current Node.js LTS, pnpm and a minimal TypeScript project that runs .ts files directly with node, with tests and a type check.

15 min Updated 2026-10-31

Many exercises and answer projects are small TypeScript programs: MCP servers, Agent SDK scripts and evaluation harnesses. This page sets up the toolchain they assume: Node.js 22.18 or newer (the current LTS is better), pnpm, and a project layout where node runs TypeScript directly, with no build step.

Before you start

  • Works on macOS, Linux and Windows. On Windows, use PowerShell.
  • If you already have Node, run node --version. Anything from v22.18.0 up can run .ts files with no flags. The current LTS (v26 at the time of writing) is the best choice, and eve needs v24 or newer.

1. Install Node.js with fnm

fnm is a fast Node version manager. It lets you switch versions per project.

macOS

brew install fnm

Linux

curl -fsSL https://fnm.vercel.app/install | bash

Windows

winget install Schniz.fnm

Next, set up your shell so fnm can put the right node on your PATH. Add the line for your shell to its profile and open a new terminal.

# ~/.zshrc (macOS default) or ~/.bashrc
eval "$(fnm env --use-on-cd --shell zsh)"   # use --shell bash in ~/.bashrc
# PowerShell profile: run `notepad $profile` to edit it
fnm env --use-on-cd --shell powershell | Out-String | Invoke-Expression

Then install the current LTS line (v26 at the time of writing; fnm install --lts also works) and make it the default:

fnm install 26
fnm default 26
node --version

If you don't want a version manager, use the installer from nodejs.org/en/download instead.

2. Install pnpm

pnpm 12 is a standalone binary. On macOS and Linux:

curl -fsSL https://get.pnpm.io/install.sh | sh -

On Windows, pnpm recommends the npm route, because Windows Defender sometimes blocks the standalone executable:

npm install -g pnpm@latest

Corepack is gone from new Node versions

Older guides use corepack enable pnpm. Node.js stopped bundling Corepack in v25, so use one of the commands above.

Open a new terminal and check the version with pnpm --version.

3. Create the project layout exercises assume

Answer projects follow this shape. Create it once to see it work:

mkdir ts-check && cd ts-check
mkdir src test
pnpm init
pnpm add -D typescript @types/node

Edit package.json so it has these fields:

package.json
{
  "name": "ts-check",
  "private": true,
  "type": "module",
  "engines": { "node": ">=22.18" },
  "scripts": {
    "start": "node --env-file-if-exists=.env src/main.ts",
    "test": "node --test",
    "typecheck": "tsc --noEmit"
  }
}

Keep the devDependencies block that pnpm add wrote; only the fields shown change.

Add the tsconfig.json that the Node docs recommend for type stripping, plus strict:

tsconfig.json
{
  "compilerOptions": {
    "target": "esnext",
    "module": "nodenext",
    "noEmit": true,
    "strict": true,
    "rewriteRelativeImportExtensions": true,
    "erasableSyntaxOnly": true,
    "verbatimModuleSyntax": true,
    "skipLibCheck": true,
    "types": ["node"]
  },
  "include": ["src", "test"]
}

Then three small files:

src/greet.ts
export function greet(name: string): string {
  return `Hello, ${name}!`;
}
src/main.ts
import { greet } from "./greet.ts";
 
console.log(greet(process.env.NAME ?? "world"));
test/greet.test.ts
import { test } from "node:test";
import assert from "node:assert/strict";
import { greet } from "../src/greet.ts";
 
test("greets by name", () => {
  assert.equal(greet("Ada"), "Hello, Ada!");
});

What each piece does:

  • node src/main.ts runs TypeScript by stripping the types. Node doesn't type-check, so pnpm typecheck runs tsc for that.
  • Imports keep the .ts extension (./greet.ts). Node requires it, and rewriteRelativeImportExtensions keeps tsc happy.
  • erasableSyntaxOnly makes tsc reject syntax Node can't strip: enum, parameter properties, namespaces with runtime code. Use union types and plain classes instead.
  • node --test finds *.test.ts files on its own, so you don't need a test framework.
  • --env-file-if-exists=.env loads settings such as your OpenRouter key (ANTHROPIC_AUTH_TOKEN or OPENAI_API_KEY) from a .env file when there is one. Add .env to .gitignore.

When to use tsx instead

If a project needs enum, tsconfig paths, or extensionless imports, run it with tsx (pnpm add -D tsx, then tsx src/main.ts). Some official quickstarts, such as the MCP and Agent SDK ones, use npx tsx, and that works too.

Check it works

pnpm install && pnpm start && pnpm test && pnpm typecheck

Expected output, trimmed:

Hello, world!
ℹ tests 1
ℹ pass 1
ℹ fail 0

pnpm typecheck prints nothing when it passes.

Troubleshooting

Unknown file extension ".ts". Your Node is older than 22.18. Run node --version. If fnm installed a newer one, the shell setup line is missing from your profile, or you haven't opened a new terminal since adding it.

Cannot find module './greet'. Add the extension: import { greet } from "./greet.ts".

An error about unsupported TypeScript syntax, often pointing at an enum. Type stripping can't handle that syntax. Rewrite it as erasable TypeScript, or run the file with tsx.

pnpm: command not found after installing. Open a new terminal; the installer edits your shell profile. On Windows, check that npm's global folder is on PATH (npm prefix -g).

Going further

  • Python with uv for the Python exercises
  • MCP servers in Claude Code, which registers a TypeScript server you write

Sources

  • Running TypeScript nativelyDocs · Node.jsWhich Node versions run `.ts` files without flags, and what type stripping can't handle.
  • Modules - TypeScriptDocs · Node.jsThe recommended `tsconfig.json`, mandatory `.ts` import extensions and other type-stripping rules.
  • fnm (Fast Node Manager)DocsInstalling fnm and setting up your shell on each OS.
  • pnpm installationDocs · pnpmThe standalone installers, the npm route and the Node compatibility table.

Exercises that use this

  • Watch the agent loop in Claude CodeAgent Foundations · What is an agent?
  • Run the same task through the Agent SDKAgent Foundations · What is an agent?
  • Build a register tool and give it to Claude CodeAgent Foundations · Tools and the agent-computer interface
  • Turn the tool into an MCP serverAgent Foundations · Tools and the agent-computer interface
  • Measure context and move procedure into a skillAgent Foundations · Context engineering
  • Isolate lease reading in a subagentAgent Foundations · Context engineering
  • Produce and verify grounded title reportsAgent Foundations · Structured outputs and grounding
  • Same report through the Agent SDKAgent Foundations · Structured outputs and grounding
  • Build a chain with a code gate, then add routingAgent Foundations · Workflow patterns
  • Orchestrator-workers and an evaluator loop with subagentsAgent Foundations · Workflow patterns
  • Build and run a 10-case evalAgent Foundations · Risk and first evals
  • Block outbound actions with a hookAgent Foundations · Risk and first evals
  • One task, two modes of the same harnessBuilding Agents with Claude and eve · Choosing a harness
  • Guardrails in Claude Code: tool, permissions, hooksBuilding Agents with Claude and eve · The Claude Agent SDK
  • Run the title-review agent on the SDKBuilding Agents with Claude and eve · The Claude Agent SDK
  • An enquiries skill and a search-reviewer subagent in Claude CodeBuilding Agents with Claude and eve · Skills and subagents
  • Port the skill and subagent to eveBuilding Agents with Claude and eve · Skills and subagents
  • A solicitor-approved send in eveBuilding Agents with Claude and eve · Human approval for high-stakes actions
  • The same gate in the Agent SDKBuilding Agents with Claude and eve · Human approval for high-stakes actions
  • Route auth and tenant isolation, checkedBuilding Agents with Claude and eve · Shipping agents
  • Deploy to Vercel with a deployable modelBuilding Agents with Claude and eve · Shipping agents
  • Write an eval charter for one agentEvaluating and Scoring Agents · Why evals, and their vocabulary
  • Run your first repeated trials in Claude CodeEvaluating and Scoring Agents · Why evals, and their vocabulary
  • Build a trace viewer and a counted taxonomyEvaluating and Scoring Agents · Error analysis from traces
  • Generate a balanced 24-task datasetEvaluating and Scoring Agents · Error analysis from traces
  • Mutation-test your gradersEvaluating and Scoring Agents · Code-based graders
  • Build a Claude Code judge and measure its position biasEvaluating and Scoring Agents · LLM-as-judge
  • Calibrate your Claude Code judge against your own labelsEvaluating and Scoring Agents · Calibrating judges
  • Pick a t.judge threshold and correct a reported rateEvaluating and Scoring Agents · Calibrating judges
  • Build a per-task rubric grader and check it criterion by criterionEvaluating and Scoring Agents · Rubrics per task
  • Draft rubrics with a model and compare them with yoursEvaluating and Scoring Agents · Rubrics per task
  • Build the naive server and measure its baselineBuilding MCP Servers · MCP and REST: two mental models
  • Generate the naive server from an OpenAPI descriptionBuilding MCP Servers · MCP and REST: two mental models
  • Write an MCP server without the SDKBuilding MCP Servers · The protocol on the wire
  • Serve 2025-era clients and watch the wireBuilding MCP Servers · The protocol on the wire
  • Build the designed larchmere-desk serverBuilding MCP Servers · Designing tools, not endpoints
  • Add response_format to search_tickets and measure itBuilding MCP Servers · Designing tools, not endpoints
  • Test the server in both protocol erasBuilding MCP Servers · Testing and evaluating servers
  • Compare the naive and designed servers with an agentBuilding MCP Servers · Testing and evaluating servers
  • Add resources, a prompt and signed confirmationsBuilding MCP Servers · Resources, prompts and asking for input
  • Serve the server over Streamable HTTPBuilding MCP Servers · Remote servers and authorization
  • Protect it as an OAuth resource serverBuilding MCP Servers · Remote servers and authorization
  • Harden the server and replay an injected agentBuilding MCP Servers · Securing MCP servers
  • Red-team the server with canaries and claude -pBuilding MCP Servers · Securing MCP servers
  • Gate a server's contract in GitHub ActionsBuilding MCP Servers · Shipping and evolving servers
  • Package the server with logs, limits and a registry entryBuilding MCP Servers · Shipping and evolving servers
  • Single agent versus lead plus subagents in Claude CodeProduction Agent Systems · Multi-agent systems
  • Fan out to eve subagents with structured resultsProduction Agent Systems · Multi-agent systems
  • Build and break an idempotent outboxProduction Agent Systems · Durable, long-running agents
  • An eve workflow tool that waits for a search resultProduction Agent Systems · Durable, long-running agents
  • Red-team and harden a pack-reading agent in Claude CodeProduction Agent Systems · Security and prompt injection
  • Fixed recipients and a locked sandbox in eveProduction Agent Systems · Security and prompt injection
  • Build a hash-chained audit log and a supervision samplerProduction Agent Systems · Compliance and auditability
  • Trace Claude Code runs and build a per-matter budget reportProduction Agent Systems · Observability and cost
  • Build a paired upgrade gate for Claude Code runsProduction Agent Systems · Continuous improvement

On this page

  • Before you start
  • 1. Install Node.js with fnm
  • macOS
  • Linux
  • Windows
  • 2. Install pnpm
  • 3. Create the project layout exercises assume
  • Check it works
  • Troubleshooting
  • Going further
  • Sources
  • Exercises that use this