
# Installation

> Install nstdlib and import its modules in your project.

## Install the package

Install [`nstdlib`](https://www.npmjs.com/package/nstdlib) with your preferred
package manager:

```sh
npm install nstdlib
```

```sh
pnpm add nstdlib
```

You can browse the published package contents on
[unpkg](https://unpkg.com/browse/nstdlib/).

## Importing from the package

Once installed, you don't import `nstdlib` itself - you import a subpath, one
per module:

```js
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](/nstdlib/usage)
and [Host](/nstdlib/host). It is generated from the actual build, not
hand-maintained. See the [API index](/api) for that list, and
each module's own page for what subpath to use and what actually works
through it.
