Kamus
2025-03-28

Getting Star...

If you’ve been in the JavaScript world for a while, you’ve probably heard of Deno—the runtime that’s been making waves as a “better Node.js.” Built by Ryan Dahl (the original creator of Node.js), Deno takes a fresh approach to running JavaScript and TypeScript, aiming to fix some of Node’s pain points while embracing modern standards. In this post, I’ll walk you through what Deno is, how it works, and how it stacks up against Node.js—especially based on my recent dive into it while tinkering with a Supabase integration.

What is Deno?

Deno is a secure, modern runtime for JavaScript and TypeScript, launched in 2020. It’s designed to be simple, safe, and developer-friendly, with built-in support for TypeScript, ES Modules, and a standard library—no extra tools required. Think of it as Node.js reimagined with lessons learned from the past decade.

Here’s a quick taste of Deno in action:

1
2
3
4
// main.ts
import { serve } from "https://deno.land/std@0.224.0/http/server.ts";

serve((req) => new Response("Hello, Deno!"), { port: 8000 });

Run it with:

1
deno run --allow-net main.ts

Boom—a web server in three lines, no npm install or node_modules in sight.

Key Features of Deno

1. TypeScript Out of the Box

Deno runs TypeScript natively—no tsconfig.json or tsc needed. Write your .ts file, run it with deno run, and Deno compiles it in memory. Compare that to Node.js, where you’d need typescript installed and a build step (or ts-node for a quicker dev loop).

2. URL-Based Imports

Forget node_modules. Deno fetches dependencies from URLs:

1
import { load } from "https://deno.land/std@0.224.0/dotenv/mod.ts";

It caches them globally (more on that later) and skips the package manager entirely.

3. Security by Default

Deno won’t let your script touch the network, filesystem, or environment unless you explicitly allow it:

1
deno run --allow-env --allow-read main.ts

This is a stark contrast to Node.js, where scripts have free rein unless you sandbox them yourself.

4. Centralized Dependency Cache

Deno stores all dependencies in a single global cache (e.g., ~/.cache/deno/deps on Unix). Run deno info to see where:

1
2
deno info
# Outputs: Modules cache: "/home/username/.cache/deno/deps"

No per-project node_modules bloating your disk.

5. Standard Library

Deno ships with a curated std library (e.g., https://deno.land/std@0.224.0), covering HTTP servers, file I/O, and even a dotenv module for .env files—stuff you’d normally grab from npm in Node.js.

Deno vs. Node.js: A Head-to-Head Comparison

I recently played with Deno to connect to Supabase, and it highlighted some big differences from Node.js. Here’s how they stack up:

Dependency Management

  • Node.js: Uses npm and package.json to install dependencies into a local node_modules folder per project. Cloning a repo? Run npm install every time.
    1
    npm install @supabase/supabase-js
  • Deno: Imports modules via URLs, cached globally at ~/.cache/deno/deps. Clone a Deno repo, and you’re ready to run—no install step.
    1
    import { createClient } from "https://esm.sh/@supabase/supabase-js@2.49.3";
  • Winner?: Deno for simplicity, Node.js for isolation (different projects can use different versions of the same module without URL juggling).

TypeScript Support

  • Node.js: Requires setup—install typescript, configure tsconfig.json, and compile to JavaScript (or use ts-node). It’s mature but clunky.
  • Deno: TypeScript runs natively. No config, no build step. Write .ts and go.
  • Winner: Deno, hands down, unless you’re stuck on a legacy Node.js workflow.

Configuration Files

  • Node.js: Relies on package.json for dependencies and scripts, often paired with tsconfig.json for TypeScript.
  • Deno: Optional deno.json for imports and settings, but not required. My Supabase script didn’t need one—just a .env file and std/dotenv.
  • Winner: Deno for minimalism.

Security

  • Node.js: Open by default. Your script can read files or hit the network without warning.
  • Deno: Locked down. Want to read .env? Add --allow-read. Network access? --allow-net. It forced me to think about permissions when connecting to Supabase.
  • Winner: Deno for safety.

Ecosystem

  • Node.js: Massive npm ecosystem—hundreds of thousands of packages. Whatever you need, it’s there.
  • Deno: Smaller but growing ecosystem via deno.land/x and CDNs like esm.sh. It worked fine for Supabase, but niche libraries might be missing.
  • Winner: Node.js for sheer volume.

Learning Curve

  • Node.js: Familiar to most JavaScript devs, but the setup (npm, TypeScript, etc.) can overwhelm beginners.
  • Deno: Fresh approach, but URL imports and permissions might feel alien if you’re Node.js-native.
  • Winner: Tie—depends on your background.

A Real-World Example: Supabase with Deno

Here’s how I set up a Supabase client in Deno:

1
2
3
4
5
6
7
8
9
10
11
12
13
import { createClient } from "https://esm.sh/@supabase/supabase-js@2.49.3";
import { load } from "https://deno.land/std@0.224.0/dotenv/mod.ts";

const env = await load({ envPath: "./.env" });
const supabaseUrl = env["SUPABASE_URL"] || Deno.env.get("SUPABASE_URL");
const supabaseKey = env["SUPABASE_ANON_KEY"] || Deno.env.get("SUPABASE_ANON_KEY");

if (!supabaseUrl || !supabaseKey) {
throw new Error("Missing SUPABASE_URL or SUPABASE_ANON_KEY");
}

const supabase = createClient(supabaseUrl, supabaseKey);
console.log("Supabase client created! Attributes:", Object.keys(supabase));

Run it:

1
deno run --allow-env --allow-read main.ts
  • .env file: SUPABASE_URL and SUPABASE_ANON_KEY (grabbed from Supabase’s dashboard—not my database password!).
  • VS Code linting needed the Deno extension and a deno cache main.ts to quiet TypeScript errors.

In Node.js, I’d have installed @supabase/supabase-js via npm, set up a dotenv package, and skipped the permissions flags. Deno’s way felt leaner but required tweaking for editor support.

Should You Use Deno?

  • Use Deno if:
    • You love TypeScript and hate build steps.
    • You want a secure, minimal setup for small projects or experiments.
    • You’re intrigued by a modern take on JavaScript runtimes.
  • Stick with Node.js if:
    • You need the npm ecosystem’s depth.
    • You’re working on a legacy project or with a team entrenched in Node.
    • You prefer per-project dependency isolation.

Wrapping Up

Deno’s not here to kill Node.js—it’s a different flavor of the same JavaScript pie. After messing with it for Supabase, I’m hooked on its simplicity and TypeScript support, but I’d still reach for Node.js on bigger, ecosystem-heavy projects. Try it yourself—spin up a Deno script, check your cache with deno info, and see if it clicks for you.

What’s your take? Node.js veteran or Deno newbie? Let me know in the comments!


This post covers Deno’s core concepts, contrasts it with Node.js, and ties in our Supabase example for a practical angle. Feel free to tweak the tone or add more details if you’re aiming for a specific audience! Want me to adjust anything?