Installation

Install nstdlib and import its modules in your project.

#Install the package

Install nstdlib with your package manager:

npm install nstdlib
pnpm add nstdlib

You can browse the published files on unpkg.

#Import a module

You don't import nstdlib itself. Instead, you import one module at a time, using the same name Node gives it, prefixed with nstdlib/node/:

import fs from "nstdlib/node/fs";
import { readFile } from "nstdlib/node/fs/promises";
In NodeWith nstdlib
node:fsnstdlib/node/fs
node:fs/promisesnstdlib/node/fs/promises
node:pathnstdlib/node/path

Besides the nstdlib/node/* modules, the package has three entries of its own, which have no Node equivalent:

ImportWhat it is
nstdlib/globalsFunctions that set up process, Buffer, a filesystem, a network and more. See Host Integration.
nstdlib/esmAn ES module compiler for runtimes that don't have one. See Host Integration.
nstdlib/embedRun whole Node programs: a filesystem, an engine and processes on it. See Usage.

#What you can import

Only the modules the package publishes can be imported. nstdlib/node/fs works because fs is published. Other files inside the package can't be imported, even though they're on disk, and neither can the shared chunks in node/_chunks/, which are an internal detail of how the package is built.

The published modules are every public node: builtin, plus a few lower-level modules that the Host Integration page uses. The full list is generated from the actual build: see the API pages, where each module's page shows its import path and what works through it.