
# Installation

> Install nstdlib and import its modules in your project.

## Install the package

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

```sh
npm install nstdlib
```

```sh
pnpm add nstdlib
```

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

## 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/`:

```js
import fs from "nstdlib/node/fs";
import { readFile } from "nstdlib/node/fs/promises";
```

| In Node            | With nstdlib               |
| ------------------ | -------------------------- |
| `node:fs`          | `nstdlib/node/fs`          |
| `node:fs/promises` | `nstdlib/node/fs/promises` |
| `node:path`        | `nstdlib/node/path`        |

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

| Import            | What it is                                                                                                                    |
| ----------------- | ----------------------------------------------------------------------------------------------------------------------------- |
| `nstdlib/globals` | Functions that set up `process`, `Buffer`, a filesystem, a network and more. See [Host Integration](/library/host-integration). |
| `nstdlib/esm`     | An ES module compiler for runtimes that don't have one. See [Host Integration](/library/host-integration#es-modules).           |
| `nstdlib/embed`   | Run whole Node programs: a filesystem, an engine and processes on it. See [Usage](/library/usage#run-a-whole-program).          |

## 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](/library/host-integration) page uses. The full list is generated
from the actual build: see the [API pages](/api), where each
module's page shows its import path and what works through it.
