Skip to main content

Node.js SDK

RBS provides hermetic Node.js support with automatic runtime management, npm-compatible package resolution, and zero reliance on the npm or yarn CLI. RBS fetches and caches all packages directly.

Setup

Toolchain

Register a Node.js toolchain in WORKSPACE.rbs:

Dependencies

Define npm packages using nodejs_repository. RBS resolves semver ranges and downloads all transitive dependencies.
RBS manages npm packages directly — no npm, yarn, or pnpm CLI is ever invoked. All packages are hermetically cached in .rbs/external-deps/.

Rules

nodejs_library

Creates a reusable Node.js library.
AttributeTypeDescription
namestringUnique target name (required).
srcslistJavaScript source files.
depslistDependencies (local targets or external packages).

nodejs_binary

Creates an executable Node.js application.
AttributeTypeDescription
namestringUnique target name (required).
srcslistJavaScript source files.
mainstringEntry point file (required).
depslistDependencies.
envdictEnvironment variables.

nodejs_test

Runs Node.js tests.

Example: Express API