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
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.
| Attribute | Type | Description |
|---|
name | string | Unique target name (required). |
srcs | list | JavaScript source files. |
deps | list | Dependencies (local targets or external packages). |
nodejs_binary
Creates an executable Node.js application.
| Attribute | Type | Description |
|---|
name | string | Unique target name (required). |
srcs | list | JavaScript source files. |
main | string | Entry point file (required). |
deps | list | Dependencies. |
env | dict | Environment variables. |
nodejs_test
Runs Node.js tests.
Example: Express API
WORKSPACE.rbs
BUILD.rbs
Commands