Installation
Install nstdlib and import its modules in your project.
#Install the package
Install nstdlib with your preferred
package manager:
npm install nstdlibpnpm add nstdlibYou can browse the published package contents on unpkg.
#Importing from the package
Once installed, you don't import nstdlib itself - you import a subpath, one
per module:
import fs from "nstdlib/fs";
import { readFile } from "nstdlib/fs/promises";The package's "exports" field is { "./*": "./dist/*.mjs" } and nothing
else. That means only the modules this project explicitly publishes as an
entry can be imported this way - nstdlib/fs works because fs is one of
them, but a path that isn't an entry, like a random file that happens to exist
inside the published tarball, cannot be imported at all. It doesn't exist as
far as your bundler or runtime is concerned.
The full, current list of importable modules includes every public node:
builtin plus a handful of host APIs documented on the next page
and Host. It is generated from the actual build, not
hand-maintained. See the API index for that list, and
each module's own page for what subpath to use and what actually works
through it.