A lightweight, custom JavaScript runtime built in Go using the Goja JS engine—designed to emulate core features of Node.js for learning and experimentation.
nodeGO is a Node.js-inspired JavaScript runtime that mimics essential features such as synchronous file system access, timers, a CommonJS-style module system, and a minimal process object. It's designed to deepen understanding of JS runtimes, event loops, and native bindings by re-implementing these behaviors in Go.
- Goja VM: Executes JavaScript.
- Runtime Layer: Written in Go, exposes native APIs to JS.
- Core Bindings: Implemented natively (console, timers, fs, etc.).
- Module Loader: Loads and executes
.jsfiles via a customrequire().
flowchart TD
A[main.go] --> B[Initialize Goja VM]
B --> C[Inject Native APIs]
C --> D[Load entry JS file]
D --> E[Execute via Goja]
console.log(msg)console.error(msg)console.warn(msg)
setTimeout(fn, delay)setInterval(fn, delay)setImmediate(fn)queueMicrotask(fn)process.nextTick(fn)
fs.readFileSync(path)fs.writeFileSync(path, data)
require(path)– supports.jsfiles- Loads and evaluates each module in isolated scope
process.cwd()process.argvprocess.envprocess.exit(code)
nodeGO/
├── main.go # Entry point
├── runtime/
│ ├── runtime.go # Core VM & event loop setup
│ ├── console.go # console APIs
│ ├── timers.go # Timers & task queues
│ ├── process.go # process object
│ ├── module.go # require() implementation
│ └── modules/
│ └── fs.go # File system bindingsgo build -o nodego main.go./nodego examples/app.js arg1 arg2console.log('Running:', process.argv);
console.log('CWD:', process.cwd());
console.log('User:', process.env.USER);
const fs = require('./test.js');
fs.hello();
setTimeout(() => {
console.log('Timeout triggered');
}, 1000);- No support for
import/export(ESM) - No asynchronous FS
- No HTTP or network APIs
- No built-in
Buffer,path,crypto, etc. - No npm support or module cache
clearTimeout/clearIntervalnot implemented yet
EventEmittercore implementation- Stream API basics
- Simple HTTP server
clearTimeout()andclearInterval()- Module caching
- Global error handling (
uncaughtException) - CLI REPL
This project is not intended to replace Node.js but to understand how it works internally by rebuilding its components from the ground up.