Skip to content


Switch branches/tags

Name already in use

A tag already exists with the provided branch name. Many Git commands accept both tag and branch names, so creating this branch may cause unexpected behavior. Are you sure you want to create this branch?

Latest commit


Git stats


Failed to load latest commit information.
Latest commit message
Commit time


Dune is an open-source, cross-platform, shell around the V8 engine, written in Rust and capable of running JavaScript (dah) and TypeScript code out of the box.

Developed completely for fun and experimentation.

GitHub GitHub Workflow Status


Mac, Linux:

curl -fsSL | sh

Windows (PowerShell)

irm | iex

Otherwise you have to manually download and unzip the release build.

From Source:

Clone the repo and build it using Cargo.

git clone && cd ./dune && cargo build --release

Make sure to create a .dune directory under your user.

Getting Started

A simple example.

import shortid from '';

console.log(shortid()); //=> "lXN1aGba2"

Another example using the net module.

import net from 'net';

const server = net.createServer(async (socket) => {
  console.log('Got new connection!');
  await socket.write('Hello! πŸ‘‹\n');
  await socket.destroy();

server.listen(3000, '', () => {
  console.log('Server is listening on port 3000...');

For more examples look at the examples directory.

Target API


  • global: reference to the global object.
  • globalThis: same as global.
  • console: a subset of the WHATWG console.
  • prompt: shows the given message and waits for the user's input.
  • TextEncoder / TextDecoder: WHATWG encoding API.
  • setTimeout / setInterval / clearTimeout / clearInterval: DOM style timers.
  • setImmediate / clearImmediate: node.js like immediate timers.
  • process: an object that provides info about the current dune process.


  • argv: an array containing the command-line arguments passed when the dune process was launched.
  • cwd(): current working directory.
  • env: an object containing the user environment.
  • exit([code]): exits the program with the given code.
  • getActiveResourcesInfo(): an array of strings containing the types of the active resources that are currently keeping the event loop alive.
  • memoryUsage(): an object describing the memory usage.
  • nextTick(cb, [...args]): adds callback to the "next tick queue".
  • pid: PID of the process.
  • platform: a string identifying the operating system platform.
  • uptime(): a number describing the amount of time (in seconds) the process is running.
  • version: the dune version.
  • versions: an object listing the version strings of dune and its dependencies.
  • binding(module): exposes modules with bindings to Rust.
  • kill(pid, [signal]): sends the signal to the process identified by pid.
  • stdout: points to system's stdout stream.
  • stdin: points to system's stdin stream.
  • stderr: points to system's stderr stream.

File System

This module should also include a Sync method for every async operation available.

  • copyFile(src, dest): copies src to dest.
  • createReadStream(path, [options]): creates a readable IO stream. 🚧
  • createWriteStream(path, [options]): creates a writable IO stream. 🚧
  • open(path, [mode]): asynchronous file open.
  • mkdir(path, [options]): creates a directory.
  • readFile(path, [options]): reads the entire contents of a file.
  • rmdir(path, [options]): deletes a directory (must be empty).
  • readdir(path): reads the contents of a directory.
  • rm(path, [options]): removes files and directories.
  • stat(path): retrieves statistics for the file.
  • writeFile(String|Uint8Array , data, [options]): writes data to the file, replacing the file if it already exists.


  • fd: the numeric file descriptor.
  • close(): closes the file.
  • createReadStream(): creates a readable IO stream. 🚧
  • createWriteStream(): creates a writable IO stream. 🚧
  • read([size, [offset]]): reads data from the file.
  • stat(): retrieves statistics for the file.
  • write(String|Uint8Array, [offset]): writes data to the file.


  • createServer([connectionListener]): Creates a new TCP server.
  • createConnection(options, [connectionListener]): Creates unix socket connection to a remote host.


Net.Server is a class extending EventEmitter.

  • listen(port, [host], [callback]): Begin accepting connections on the specified port and host.
  • close([callback]): Stops the server from accepting new connections and keeps existing connections.
  • address(): Returns the bound address.
  • getConnections(): Get the number of concurrent connections on the server.
  • Event: 'listening': Emitted when the server has been bound after calling server.listen.
  • Event: 'connection': Emitted when a new connection is made.
  • Event: 'close': Emitted when the server closes.
  • Event: 'error': Emitted when an error occurs.


Net.Socket is a class extending EventEmitter.

  • connect(options, [connectionListener]): Opens the connection for a given socket.
  • setEncoding(encoding): Set the encoding for the socket.
  • write(data, [callback]): Sends data on the socket.
  • end([data]): Half-closes the socket. i.e., it sends a FIN packet.
  • destroy(): Closes and discards the TCP socket stream.
  • address(): Returns the bound address.
  • remoteAddress: The string representation of the remote IP address.
  • remotePort: The numeric representation of the remote port.
  • bytesRead: The amount of received bytes.
  • bytesWritten: The amount of bytes sent.
  • Event: 'connect': Emitted when a socket connection is successfully established.
  • Event: 'data': Emitted when data is received.
  • Event: 'end': Emitted when the other end of the socket sends a FIN packet.
  • Event: 'error': Emitted when an error occurs.
  • Event: 'close': Emitted once the socket is fully closed.

Performance Measurement

  • timeOrigin: specifies the millisecond timestamp at which the current process began.
  • now(): returns the millisecond timestamp, where 0 represents the start of the current process.


The assertion API is copied from:

  • true(value): asserts that value is equal to true.
  • false(value): asserts that value is equal to false.
  • instanceOf(value, class): asserts that value is an instance of specific class.
  • integer(value): asserts that value is valid integer.
  • number(value): asserts that value is valid number (integer, float).
  • oddNumber(value): asserts that value is odd number.
  • evenNumber(value): asserts that value is event number.
  • greaterThan(value, limit): asserts that number is greater than.
  • greaterThanOrEqual(value, limit): asserts that number is greater than or equal.
  • lessThan(value, limit): asserts that number is less than.
  • lessThanOrEqual(value, limit): asserts that number is less than or equal.
  • string(value): asserts that value is valid string.
  • boolean(value): asserts that value is valid boolean.
  • equal(actual, expected): asserts that value is equal to expected value.
  • objectEqual(actual, expected): asserts that value is equal to expected value.
  • object(value): asserts that value is valid object.
  • hasFunction(name, object): asserts that object has function.
  • hasProperty(name, object): asserts that object has property.
  • isFunction(fn): asserts that value is valid function.
  • array(value): asserts that value is valid array.
  • count(expected, arrayValue): asserts that array have specific number of elements.
  • notEmpty(arrayValue): asserts that array is not empty.
  • throws(fn, error): asserts that function throws expected exception.


Contributions are always welcome!

See for ways to get started.


A hobby runtime for JavaScript and TypeScript πŸš€



Code of conduct





No packages published