node-wasm
A full Node.js runtime running entirely in the browser, powered by libuv compiled to WebAssembly. No server required — everything runs client-side.
Screenshots
| Editor |
Shell |
 |
 |
| Code Generator |
Live Preview |
 |
 |
Features
- Complete Node.js API —
fs, path, http, events, stream, buffer, crypto, net, child_process, querystring and more, all reimplemented for the browser
- In-Memory Filesystem — Full POSIX-like filesystem (MEMFS) with
readFile, writeFile, mkdir, stat, readdir, symlinks, streams, and watch
- HTTP Server & Client —
http.createServer() works via Service Worker interception; http.request() supports both virtual servers and real external URLs via fetch()
- npm Package Manager — Install real npm packages (
npm install react, npm install lodash) directly in the browser; fetches from unpkg CDN with recursive dependency resolution
- Next.js Framework — Built-in mini-Next.js with file-based routing, JSX/SSR,
getServerSideProps, getStaticProps, _app.js, _document.js, dynamic routes ([slug].js), and API routes
- JSX Transpiler — Hand-written recursive descent parser that handles ternaries, logical expressions,
.map() with inline JSX, fragments, spread props, comments, and deeply nested structures
- Code Generator — AI-powered project scaffolding that generates complete Next.js projects with streaming file-by-file output
- Interactive Shell — Terminal with tab completion, command history, and support for
ls, cat, mkdir, cd, echo, node, npm, and more
- Node.js REPL — Type
node to enter an interactive JavaScript environment with persistent scope and full require() support
- Live Preview — Embedded browser preview with URL bar, back/forward navigation, and SPA-style client-side routing
Architecture
┌──────────────────────────────────────────┐
│ Interactive Web IDE │ ← Shell + Editor + Preview
├──────────────────────────────────────────┤
│ Virtual npm / Next.js / Code Generator │ ← High-level frameworks
├──────────────────────────────────────────┤
│ Node.js stdlib (fs, http, path, ...) │ ← Pure JS reimplementation
├──────────────────────────────────────────┤
│ Service Worker (nw-sw.js) │ ← HTTP request interception
├──────────────────────────────────────────┤
│ C runtime + libuv → WebAssembly │ ← Emscripten compiled
├──────────────────────────────────────────┤
│ MEMFS + Browser APIs │ ← Storage & I/O layer
├──────────────────────────────────────────┤
│ Browser │
└──────────────────────────────────────────┘
How It Works
- libuv is cross-compiled to WebAssembly via Emscripten, providing the event loop and low-level I/O primitives
- Node.js standard library modules are reimplemented in pure JavaScript, backed by Emscripten's in-memory filesystem (MEMFS)
- A Service Worker intercepts HTTP requests to virtual server ports (
/nw-server/{port}/...), forwarding them to the in-browser http.createServer() handler via MessageChannel
- The npm client fetches packages from unpkg CDN, parses
package.json, and recursively resolves local require() dependencies into MEMFS /node_modules/
- The JSX transpiler converts JSX syntax to
React.createElement() calls at request time, enabling SSR with renderToString()
- The mini-Next.js framework scans a
pages/ directory, matches URL routes, loads page modules with JSX transpilation, runs data-fetching functions, and returns fully rendered HTML
Quick Start
# 1. Activate Emscripten SDK
source /path/to/emsdk/emsdk_env.sh
# 2. Build libuv to WASM
./scripts/build-libuv.sh
# 3. Build the node-wasm runtime
./scripts/build-runtime.sh
# 4. Start the dev server
cd web && python3 serve.py 8080
Then open http://localhost:8080 in your browser — you'll get a full Node.js development environment with shell, editor, and live preview.
Project Structure
node-wasm/
├── deps/libuv/ # libuv source (git submodule)
├── src/
│ ├── runtime.c # C binding layer (JS ↔ WASM bridge)
│ └── uv_platform_shim.c # Platform-specific shims
├── scripts/
│ ├── build-libuv.sh # Cross-compile libuv → WASM
│ └── build-runtime.sh # Build the full runtime
└── web/
├── index.html # Main IDE UI (shell + editor + preview)
├── node-wasm.js # Emscripten-generated JS glue
├── node-wasm.wasm # Compiled WASM binary
├── node-runtime.js # Runtime bootstrap & module loader
├── nw-sw.js # Service Worker for HTTP interception
├── serve.py # Dev server with WASM MIME support
└── lib/
├── fs.js # File system (MEMFS-backed)
├── http.js # HTTP server & client
├── path.js # Path utilities
├── events.js # EventEmitter
├── stream.js # Readable/Writable/Transform streams
├── buffer.js # Buffer implementation
├── net.js # TCP sockets (virtual)
├── crypto.js # Crypto utilities
├── child_process.js # Process spawning (virtual)
├── querystring.js # Query string parsing
├── npm.js # Virtual npm package manager
├── next.js # Mini Next.js framework
├── jsx-runtime.js # JSX transpiler
├── codegen.js # AI project code generator
└── sw-bridge.js # Service Worker communication bridge
License
MIT