Deno 2: The Node.js Alternative That Now Runs npm Packages

Updated
7 min read
Deno 2: The Node.js Alternative That Now Runs npm Packages
TL;DR

Deno 2 drops in npm and Node.js compatibility while keeping its permission model and built-in TypeScript - here is what changed, what still differs, and when to choose it.

Deno 2: The Compatibility Release

Deno's original pitch was compelling: TypeScript out of the box, URL imports, a secure-by-default permission model. But it ran almost no npm packages - which excluded 95% of the JavaScript ecosystem. Deno 2 fixes that without abandoning what made Deno good.

npm and Node.js Compatibility

Deno 2 can run most npm packages with the npm: specifier:

typescript
// deno run --allow-net server.ts
import express from "npm:express";

const app = express();
app.get("/", (req, res) => res.json({ hello: "world" }));
app.listen(3000);

Or with a package.json and deno install:

json
{
  "imports": {
    "express": "npm:express@4",
    "zod": "npm:zod@3"
  }
}
bash
deno install   # reads package.json, installs to Deno's global cache
deno run server.ts

Node.js built-in modules (node:fs, node:path, node:http) are fully supported. Most Express/Fastify/Hapi applications run without changes.

The Permission Model

Unlike Node.js, Deno requires explicit permission grants. No permission = no access:

bash
# Grant specific permissions
deno run   --allow-net=api.example.com:443   --allow-read=/tmp   --allow-env=DATABASE_URL   server.ts

# Grant all (not recommended)
deno run --allow-all server.ts

This is the biggest operational difference from Node.js. In CI or production, you define exactly what the script is allowed to do. No surprise file system access from a malicious dependency.

JSR - The JavaScript Registry

JSR (jsr.io) is Deno's alternative to npm, designed from the start for TypeScript:

typescript
// Native Deno packages  -  no build step, TypeScript source published directly
import { z } from "jsr:@zod/zod";
import { Hono } from "jsr:@hono/hono";

JSR packages are TypeScript-first, have enforced documentation, and are scored on quality metrics. They work in both Deno and Node.js (JSR generates npm-compatible builds automatically).

Built-In TypeScript - No Config

bash
# TypeScript works with zero config
deno run server.ts      # no ts-node, no tsx, no tsc compile step
deno check server.ts    # type checking only

Deno bundles its own TypeScript compiler. No tsconfig.json is required (though you can use one for IDE support).

deno compile - Single Executables

bash
# Compile to a standalone binary  -  no Deno runtime needed on the target machine
deno compile --allow-net --allow-read server.ts

# Cross-compile for different platforms
deno compile --target x86_64-pc-windows-msvc server.ts
deno compile --target x86_64-apple-darwin server.ts

The resulting binary includes the Deno runtime, your code, and all dependencies.

Performance Comparison vs Node.js

On an M2 Pro, identical HTTP server:

Click any column to sort
4 rows
HTTP req/s (no framework)98,00082,000
File read (1MB)1.2ms1.4ms
Startup time12ms45ms
TypeScript startup (no compile)15ms380ms (tsx)

Deno's TypeScript startup is the clearest win - no compilation step means fast restarts.

Deno Deploy - Edge Runtime

Deploy to Deno's global edge network:

bash
deno install -A jsr:@deno/deployctl
deployctl deploy --project=my-app server.ts

Deno Deploy runs on 35+ regions, starts in under 1ms (V8 isolates, same model as Cloudflare Workers), and has a generous free tier.

References: Deno 2 · Deno Deploy · JSR

#deno-2#node.js-alternative#typescript#npm-compatibility#security

One AI engineering post, weekly

LLM benchmarks, prompt techniques, and token-cost breakdowns, delivered to your inbox.

What should we test or explain next?

Comments

Have a question or something to add? Sign in to join the discussion.

Mahmudul Haque Qudrati — CEO & ML Engineer at Pristren

Mahmudul Haque Qudrati

CEO & ML Engineer

Software architect, full-stack engineer, and machine learning practitioner. Founder & CEO of Pristren, CTO at Venture Kick-backed PIN Sport Application GmbH (Basel, Switzerland), Software Development Lead at DailyFrame GmbH (building Dimetra patient transport software), and creator of Zlyqor. Focused on custom workflow automation, scalable web and mobile applications, and production AI/ML systems.