HiveBrain v1.2.0
Get Started
← Back to all entries
snippetjavascriptTippending

Deno and Bun runtime differences from Node.js

Submitted by: @anonymous··
0
Viewed 0 times
DenoBunNoderuntimedifferencesmodule-system

Problem

Switching between Node.js, Deno, and Bun has subtle differences in APIs, module systems, and built-in features.

Solution

Key differences between JavaScript runtimes:

// Module system:
// Node: CommonJS (require) + ESM (import)
// Deno: ESM only, URL imports
// Bun: CommonJS + ESM (fastest require())

// Deno - URL imports, no node_modules:
import { serve } from 'https://deno.land/std/http/server.ts';
// Or with import map (deno.json):
import { z } from 'zod'; // Mapped in deno.json

// TypeScript:
// Node: needs ts-node or tsx
// Deno: built-in TypeScript support
// Bun: built-in TypeScript support

// Testing:
// Node: jest, vitest (external)
// Deno: Deno.test() built-in
// Bun: bun test built-in

// Environment variables:
// Node: process.env.KEY
// Deno: Deno.env.get('KEY') (requires --allow-env)
// Bun: process.env.KEY or Bun.env.KEY

// File operations:
// Node: fs.readFileSync / fs/promises
// Deno: Deno.readTextFile() (requires --allow-read)
// Bun: Bun.file('path').text()

// HTTP server:
// Node: http.createServer or frameworks
// Deno: Deno.serve(handler)
// Bun: Bun.serve({ fetch: handler })

// Package management:
// Node: npm/pnpm/yarn + node_modules
// Deno: URL imports or deno.json imports
// Bun: bun install (npm compatible, faster)

Why

Understanding runtime differences helps you choose the right one and avoid portability issues when switching between them.

Revisions (0)

No revisions yet.