Deno Complete Guide | Secure JavaScript Runtime, Deno 2.0
이 글의 핵심
Deno is a secure-by-default JavaScript and TypeScript runtime with built-in tooling ??no node_modules, no package.json, native TypeScript support. Deno 2.0 adds npm compatibility, making it a drop-in upgrade path from Node.js.
What This Guide Covers
Deno is a modern runtime for JavaScript and TypeScript that prioritizes security, simplicity, and developer experience. This guide covers Deno 2.0 ??from first script to HTTP servers, CLI tools, and deployment.
Real-world insight: Replacing a bash script with a Deno script cut maintenance time in half ??native TypeScript, no setup, single binary deployment.
Real-World Adoption
Deno represents a fresh take on JavaScript runtime design:
Created by Ryan Dahl:
- Node.js original creator - learned from 10 years of Node.js design
- Announced at JSConf 2018 - “10 Things I Regret About Node.js” talk
- Written in Rust - memory safety, security-first architecture
- Funded by multiple rounds - $25M+ raised to build Deno Company
Enterprise Usage:
- Slack: Experimenting with Deno for automation scripts
- GitHub: Using Deno for internal tooling
- Netlify: Deno Deploy integration for edge functions
- Supabase: Offers Deno Edge Functions (alternative to Node)
Market Position:
- 1+ million weekly npm downloads (April 2026)
- 94,000+ GitHub stars - massive community interest
- Deno Deploy: 100,000+ deployed projects
- Used in 200,000+ repositories
Why Deno Was Built:
- Security by default: Explicit permissions (no accidental file access)
- No node_modules: URL imports, no package.json dependency hell
- TypeScript native: Zero config, instant execution
- Modern APIs: Web standard APIs (fetch, WebSocket, etc.)
- Single executable: No separate node + npm installs
Deno 2.0 Key Improvements (2024):
- npm compatibility: Use 2M+ npm packages via
npm:specifier - Long-term support: Deno 2.0 LTS with 2+ years support
- Faster: 2-3x faster startup than Deno 1.x
- Better Node compat: 90%+ Node.js API compatibility
Production Deployments:
- Deno Deploy: Edge runtime (alternative to Cloudflare Workers)
- Fresh framework: Zero-config SSR (10,000+ production sites)
- JSR (JavaScript Registry): Modern npm alternative (TypeScript-first)
When to Choose Deno:
- ??New scripts and CLIs (best DX)
- ??Edge functions (Deno Deploy)
- ??TypeScript projects (zero config)
- ??Security-critical applications
- ??Projects starting fresh
- ??Large Node.js migrations (test thoroughly)
- ??Projects with many Node-specific packages
- ??Teams requiring npm ecosystem 100%
Deno vs Node vs Bun:
- Node.js: Most mature, largest ecosystem (14 years old)
- Deno: Most secure, best TypeScript DX, modern APIs
- Bun: Fastest performance, all-in-one tooling
Community Innovations:
- JSR: TypeScript-native package registry (npm alternative)
- Fresh: Island architecture framework (less JS shipped)
- Deno Deploy: Edge runtime with zero-config deployments
Deno 2.0’s npm compatibility makes it a viable Node.js upgrade path - you get modern runtime benefits while keeping access to the npm ecosystem.
Installation
# macOS / Linux
curl -fsSL https://deno.land/install.sh | sh
# Windows
irm https://deno.land/install.ps1 | iex
# Via Homebrew
brew install deno
deno --version
# deno 2.x.x
1. Running TypeScript Without Configuration
// hello.ts
const greet = (name: string): string => `Hello, ${name}!`;
console.log(greet("Deno"));
deno run hello.ts
# No tsconfig.json, no compilation step needed
2. Permissions (Secure by Default)
Deno denies all external access by default. You must explicitly grant permissions:
# Network access
deno run --allow-net server.ts
# File read
deno run --allow-read=./data script.ts
# File write
deno run --allow-write=/tmp script.ts
# Environment variables
deno run --allow-env=API_KEY script.ts
# Run subprocesses
deno run --allow-run=git script.ts
# All permissions (use sparingly)
deno run --allow-all script.ts
Scope permissions as narrowly as possible ??--allow-net=api.example.com instead of --allow-net.
3. Standard Library
Deno ships a comprehensive standard library ??no npm needed for common tasks:
// File operations
import { exists, readTextFile, writeTextFile } from "jsr:@std/fs";
if (await exists("./config.json")) {
const config = await readTextFile("./config.json");
console.log(JSON.parse(config));
}
// HTTP client
const response = await fetch("https://api.github.com/users/denoland");
const user = await response.json();
console.log(user.login);
// Path utilities
import { join, dirname, basename } from "jsr:@std/path";
const filePath = join(Deno.cwd(), "data", "users.json");
// Date formatting
import { format } from "jsr:@std/datetime";
console.log(format(new Date(), "yyyy-MM-dd"));
4. HTTP Server
// server.ts
Deno.serve({ port: 8080 }, (req: Request) => {
const url = new URL(req.url);
if (url.pathname === "/health") {
return Response.json({ status: "ok" });
}
if (url.pathname === "/users" && req.method === "GET") {
return Response.json([
{ id: 1, name: "Alice" },
{ id: 2, name: "Bob" },
]);
}
return new Response("Not Found", { status: 404 });
});
console.log("Server running on http://localhost:8080");
deno run --allow-net server.ts
Deno’s server uses the standard Web Request/Response API ??same as Cloudflare Workers and edge runtimes.
5. npm Compatibility (Deno 2.0)
// Use npm packages with the npm: specifier
import express from "npm:express";
import { z } from "npm:zod";
import chalk from "npm:chalk";
const app = express();
const UserSchema = z.object({
name: z.string(),
email: z.string().email(),
});
app.post("/users", express.json(), (req, res) => {
const result = UserSchema.safeParse(req.body);
if (!result.success) {
return res.status(400).json({ errors: result.error.issues });
}
res.json({ created: result.data });
});
app.listen(3000);
No npm install needed ??Deno caches packages automatically.
6. Deno.json ??Configuration
{
"tasks": {
"dev": "deno run --allow-net --allow-read --watch src/server.ts",
"test": "deno test --allow-net",
"fmt": "deno fmt",
"lint": "deno lint"
},
"imports": {
"@std/": "jsr:@std/",
"zod": "npm:zod@3",
"hono": "jsr:@hono/hono@4"
},
"lint": {
"rules": { "tags": ["recommended"] }
},
"fmt": {
"lineWidth": 100,
"singleQuote": true
}
}
deno task dev # run dev server with hot reload
deno task test # run tests
7. Testing
// math_test.ts
import { assertEquals, assertThrows } from "jsr:@std/assert";
function divide(a: number, b: number): number {
if (b === 0) throw new Error("Division by zero");
return a / b;
}
Deno.test("divide works correctly", () => {
assertEquals(divide(10, 2), 5);
assertEquals(divide(9, 3), 3);
});
Deno.test("divide throws on zero", () => {
assertThrows(() => divide(5, 0), Error, "Division by zero");
});
// Async test
Deno.test("fetch works", async () => {
const res = await fetch("https://httpbin.org/get");
assertEquals(res.status, 200);
});
deno test --allow-net
8. CLI Tools
Deno excels at building cross-platform CLI tools:
// cli.ts
const args = Deno.args;
if (args.length === 0) {
console.error("Usage: deno run cli.ts <command>");
Deno.exit(1);
}
const [command, ...rest] = args;
switch (command) {
case "hello":
console.log(`Hello, ${rest[0] || "World"}!`);
break;
case "env":
console.log(Deno.env.toObject());
break;
default:
console.error(`Unknown command: ${command}`);
Deno.exit(1);
}
Compile to a standalone binary:
deno compile --allow-env --output mycli cli.ts
./mycli hello Deno
Single binary, no runtime needed ??works on macOS, Linux, Windows.
9. Hono ??Fast Web Framework
Hono is the recommended web framework for Deno (also works on Cloudflare Workers, Bun, Node):
import { Hono } from "jsr:@hono/hono";
const app = new Hono();
app.get("/", (c) => c.text("Hello Deno!"));
app.get("/users/:id", (c) => {
const id = c.req.param("id");
return c.json({ id, name: "Alice" });
});
app.post("/users", async (c) => {
const body = await c.req.json();
return c.json({ created: body }, 201);
});
Deno.serve(app.fetch);
10. Deployment
Deno Deploy (edge, free tier)
# Install deployctl
deno install -A jsr:@deno/deployctl
# Deploy
deployctl deploy --project=my-app server.ts
Deno Deploy runs your code across 35+ edge locations globally.
Docker
FROM denoland/deno:2.0.0
WORKDIR /app
COPY deno.json .
COPY src/ ./src/
RUN deno cache src/server.ts
CMD ["deno", "run", "--allow-net", "--allow-env", "src/server.ts"]
Built-in Tooling
No separate tools to install:
deno fmt # format (like Prettier)
deno lint # lint (like ESLint)
deno check # type-check without running
deno doc # generate documentation
deno bench # run benchmarks
deno compile # bundle to standalone binary
deno jupyter # Jupyter notebook support
Key Takeaways
| Feature | Deno |
|---|---|
| TypeScript | Built-in, no config |
| Security | Deny-all by default, explicit permissions |
| Package manager | None ??URL/JSR/npm: imports + cache |
| Tooling | fmt, lint, test, compile all built-in |
| npm compat | Full (Deno 2.0+) |
| Edge deploy | Deno Deploy (35+ locations) |
Deno is production-ready for new projects, especially scripts, CLIs, APIs, and edge workers. The security model and built-in TypeScript make it particularly attractive for teams that want a lean, secure runtime without the Node.js ecosystem’s configuration overhead.
?�주 묻는 질문 (FAQ)
Q. ???�용???�무?�서 ?�제 ?�나??
A. Master Deno 2.0 ??the secure TypeScript runtime by Node.js creator Ryan Dahl. Covers permissions, std library, npm compa???�무?�서????본문???�제?� ?�택 가?�드�?참고???�용?�면 ?�니??
Q. ?�행?�로 ?�으�?좋�? 글?�?
A. �?글 ?�단???�전 글 ?�는 관??글 링크�??�라가�??�서?��?배울 ???�습?�다. C++ ?�리�?목차?�서 ?�체 ?�름???�인?????�습?�다.
Q. ??깊이 공�??�려�?
A. cppreference?� ?�당 ?�이브러�?공식 문서�?참고?�세?? 글 말�???참고 ?�료 링크???�용?�면 좋습?�다.
같이 보면 좋�? 글 (?��? 링크)
??주제?� ?�결?�는 ?�른 글?�니??
- [Express REST API Tutorial for Node.js | Routing](/en/blog/nodejs-express-rest-api-tutorial/
- [TypeScript 5 Complete Guide | Decorators· satisfies](/en/blog/typescript-5-complete-guide/
??글?�서 ?�루???�워??(관??검?�어)
Deno, JavaScript, TypeScript, Runtime, Backend, Fresh ?�으�?검?�하?�면 ??글???��????�니??