Development Setup
Prerequisites
Node.js (Version: >=20.6)
Bun (Version: >=1.2.1)
Environment Setup
Our development environment is managed through nix-shell, which ensures consistent dependencies across all development machines.
To get started:
Enter the development environment:
nix-shellSet up the GitBook repository:
setupStart the development server:
dev
Available Commands
GitBook Development
setup- Clone and setup GitBook repositorysetup-force- Force setup (removes existing directory)update- Update existing GitBook repositoryrebuild- Rebuild GitBook packages if there are module errorsdev- Start the development servergformat- Format GitBook codebaseglint- Lint GitBook codebase
Markdown Formatting
fmt- Format Markdown fileslint- Lint Markdown filescheck- Check formatting
Troubleshooting
Module Resolution Errors
If you encounter errors like:
Error: Cannot find module '/path/to/gitbook/node_modules/@gitbook/colors/dist/index.js'Run the rebuild script:
rebuildThis script:
Cleans previous build artifacts
Reinstalls dependencies with
bun install --forceRebuilds all packages
After completion, try running dev again to start the development server.
Repository Already Exists
If you get an error about the GitBook directory already existing:
fatal: destination path 'gitbook' already exists and is not an empty directory.Use one of these commands:
update- Pull latest changes if the repository existssetup-force- Remove existing directory and set up fresh
Development Server
The GitBook development server will be available at:
http://localhost:3000/url/docs.gitbook.comYou can access any published GitBook space by prefixing its URL with http://localhost:3000/url/.
For example:
http://localhost:3000/url/docs.gitbook.comhttp://localhost:3000/url/open-source.gitbook.io/midjourney
Last updated