dop251/goja_nodejs

Nodejs compatibility library for Goja

Go

441

91 commits

updated Sep 18, 2026

See the code

README

Nodejs compatibility library for Goja

This is a collection of Goja modules that provide nodejs compatibility.

Example:

package main

import (
    "github.com/dop251/goja"
    "github.com/dop251/goja_nodejs/require"
)

func main() {
    registry := new(require.Registry) // this can be shared by multiple runtimes

    runtime := goja.New()
    req := registry.Enable(runtime)

    runtime.RunString(`
    var m = require("./m.js");
    m.test();
    `)

    m, err := req.Require("./m.js")
    _, _ = m, err
}

Type Definitions

Type definitions are published to https://npmjs.com as @dop251/types-goja_nodejs-MODULE. They only include what's been implemented so far.

To make use of them you need to install the appropriate modules and add node_modules/@dop251 to typeRoots in tsconfig.json.

I didn't want to add those to DefinitelyTyped partly because I don't think they really belong there, and partly because I'd like to fully control the release cycle, i.e. publish the modules by an automated CI job and exactly at the same time as the Go code is released.

And the reason for splitting them into different packages is that the modules can be enabled or disabled individually, unlike in nodejs.

More modules will be added. Contributions welcome too.

dop251/goja_nodejs

Nodejs compatibility library for Goja

Go

441

91 commits

updated Sep 18, 2026

See the code

README

Nodejs compatibility library for Goja

This is a collection of Goja modules that provide nodejs compatibility.

Example:

package main

import (
    "github.com/dop251/goja"
    "github.com/dop251/goja_nodejs/require"
)

func main() {
    registry := new(require.Registry) // this can be shared by multiple runtimes

    runtime := goja.New()
    req := registry.Enable(runtime)

    runtime.RunString(`
    var m = require("./m.js");
    m.test();
    `)

    m, err := req.Require("./m.js")
    _, _ = m, err
}

Type Definitions

Type definitions are published to https://npmjs.com as @dop251/types-goja_nodejs-MODULE. They only include what's been implemented so far.

To make use of them you need to install the appropriate modules and add node_modules/@dop251 to typeRoots in tsconfig.json.

I didn't want to add those to DefinitelyTyped partly because I don't think they really belong there, and partly because I'd like to fully control the release cycle, i.e. publish the modules by an automated CI job and exactly at the same time as the Go code is released.

And the reason for splitting them into different packages is that the modules can be enabled or disabled individually, unlike in nodejs.

More modules will be added. Contributions welcome too.

Significant stargazers

James Sumners

407 followers · starred Oct 2022

Hanchin Hsieh

50 followers · starred Mar 2026

Cyberhan123

20 followers · starred Sep 2023

yanminmin

23 followers · starred Dec 2022