Skip to content
Home / Migrations / Node.jsDeno 2

Node.js Deno 2

medium

Deno 2 is Node-compatible: npm packages work, node: builtins work, package.json supported. Migration is mostly removing boilerplate and fixing path imports.

Estimated: 4-12h · 7 steps
Progress0%
Step 1: Install Deno 2
curl -fsSL https://deno.land/install.sh | sh
Step 2: Run Node project directly

Try running your entry point — Deno 2 reads package.json and resolves npm deps automatically.

deno run --allow-all src/index.ts
Step 3: Fix import extensions

Deno requires explicit .ts extensions in local imports: import './utils' → import './utils.ts'.

Step 4: Update std library usage

Node built-ins still work via node: prefix. Deno's own std is at jsr:@std/. Use JSR for new dependencies where available.

Step 5: Replace process with Deno APIs

process.env → Deno.env.get(). process.exit() → Deno.exit(). __dirname → import.meta.dirname.

Step 6: Set up deno.json

Add deno.json for tasks, permissions, import aliases. Replaces package.json scripts for Deno-native workflow.

{ "tasks": { "dev": "deno run --watch --allow-all src/index.ts" } }
Step 7: Verify with lint + test
deno lint && deno test
All tests pass under Deno runtime