> ## Documentation Index
> Fetch the complete documentation index at: https://bakefile.wisl.dev/llms.txt
> Use this file to discover all available pages before exploring further.

> ## Agent Instructions
> bakefile is a Python task runner with two CLIs: bake runs tasks from bakefile.py, bakefile manages the project. It is not a service or platform.
> Tasks are methods on Bakebook classes in bakefile.py, decorated with @command. Subprocesses run through self.ctx.run().
> Examples are backed by tests; copy them verbatim.

# Node Spaces

> BunSpace and NpmSpace run a Node repo's setup, lint, test and build through its own package.json scripts.

A Node repo picks its package manager explicitly: compose `BunSpace` or `NpmSpace`. Both build on `BaseNodeSpace`, which keeps the repo's own JS tooling and only forwards to its `package.json` scripts.

```python theme={"theme":{"light":"github-light","dark":"github-dark"}}
from bakelib import BunSpace

bakebook = BunSpace()
```

## What `BaseNodeSpace` adds

* `node` in mise, and `node` among the required CLI tools (`bake tools`)
* the `Node` template from github/gitignore in the managed `.gitignore` ([Managed content](https://bakefile.wisl.dev/bakelib/managed-content.md))
* `bake lint` runs the `lint` script after the `BaseSpace` checks, and skips it when `package.json` has none
* `bake test` runs the `test` script and `bake build` runs the `build` script; either one reports the command as not available when its script is missing

`BaseNodeSpace` does nothing on its own: it does not know which package manager to run. Use one of the Spaces below.

## Package managers

| Space | Runs scripts with | `bake setup-dev` installs with | `bake update` runs | Its lockfiles |
| - | - | - | - | - |
| `BunSpace` | `bun run <name>` | `bun install --frozen-lockfile` | `bun update` | `bun.lock`, `bun.lockb` |
| `NpmSpace` | `npm run <name>` | `npm ci` | `npm update` | `package-lock.json`, `npm-shrinkwrap.json` |

The Space never picks the package manager from the lockfiles it finds, because stray lockfiles happen. Instead, `bake lint` fails on a **stray lockfile**, a lockfile of another package manager (`package-lock.json`, `pnpm-lock.yaml`, `yarn.lock` in a `BunSpace` repo), and names it so you delete it.

pnpm and yarn have no Space yet.

## Adding scripts or steps

Override the hooks, not the commands, as with any Space:

```python theme={"theme":{"light":"github-light","dark":"github-dark"}}
from bakelib import NpmSpace


class MyBakebook(NpmSpace):
    def _lint_fast(self) -> None:
        super()._lint_fast()
        self._run_script("typecheck")


bakebook = MyBakebook()
```


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.