Skip to main content
GraphDoc can be installed globally via npm, run directly with npx, or built from source. Choose the installation method that best fits your workflow.

Prerequisites

Before installing GraphDoc, ensure you have the following installed:
  • Node.js: Version 10 or higher recommended
  • npm: Comes bundled with Node.js
You can verify your Node.js and npm versions by running:
node --version
npm --version
The easiest way to use GraphDoc is to install it globally via npm. This makes the graphdoc command available system-wide.
npm install -g @2fd/graphdoc
After installation, verify that GraphDoc is installed correctly:
graphdoc --version
You should see output like:
graphdoc v2.4.0
The package name is @2fd/graphdoc, but the command is just graphdoc.

Global vs local installation

You can also install GraphDoc locally in your project:
npm install --save-dev @2fd/graphdoc
Then run it via npm scripts or npx:
{
  "scripts": {
    "docs": "graphdoc -e http://localhost:8080/graphql -o ./docs"
  },
  "devDependencies": {
    "@2fd/graphdoc": "^2.4.0"
  }
}

Run with npx

If you don’t want to install GraphDoc permanently, you can run it directly with npx. This downloads and executes the package in a single command:
npx @2fd/graphdoc -e http://localhost:8080/graphql -o ./docs
This approach is useful for:
  • One-time documentation generation: When you don’t need GraphDoc installed permanently
  • CI/CD pipelines: Ensures you always use the latest version without managing dependencies
  • Quick testing: Try GraphDoc without committing to an installation
Using npx will download the package each time unless it’s cached. For repeated use, installing globally or locally is more efficient.

Install from source

For development or to use the latest unreleased features, you can install GraphDoc from the GitHub repository.
1

Clone the repository

git clone https://github.com/2fd/graphdoc.git
cd graphdoc
2

Install dependencies

npm install
3

Compile TypeScript

GraphDoc is written in TypeScript and must be compiled before use:
npm run compile
4

Link for global use (optional)

To use your local build globally:
npm link
Now you can run graphdoc from anywhere on your system.

Running from source

Without linking, you can run GraphDoc directly from the repository:
node bin/graphdoc.js -e http://localhost:8080/graphql -o ./docs
The GraphDoc repository includes several helpful npm scripts:
  • npm run compile - Compile TypeScript to JavaScript
  • npm run declaration - Generate TypeScript declaration files
  • npm test - Run the test suite with Jest
  • npm run doc.github - Generate GitHub API documentation example
  • npm run doc.pokemon - Generate Pokemon API documentation example
  • npm run doc.shopify - Generate Shopify API documentation example

Verify installation

Regardless of your installation method, verify that GraphDoc is working correctly:
graphdoc --version

Update GraphDoc

To update to the latest version of GraphDoc:
npm update -g @2fd/graphdoc

Uninstall GraphDoc

If you need to remove GraphDoc:
npm uninstall -g @2fd/graphdoc

Troubleshooting

On Unix-based systems, you might encounter permission errors when installing globally. You have two options:Option 1: Use npx instead (recommended)
npx @2fd/graphdoc -e http://localhost:8080/graphql -o ./docs
Option 2: Fix npm permissions Follow npm’s official guide to resolve permission issues.
If graphdoc command is not found after global installation:
  1. Verify the installation:
    npm list -g @2fd/graphdoc
    
  2. Check your npm global bin path is in your PATH:
    npm config get prefix
    
  3. Add npm’s bin directory to your PATH if needed:
    export PATH="$(npm config get prefix)/bin:$PATH"
    
Ensure you’re using a compatible TypeScript version:
npm install
npm run compile
If errors persist, try cleaning and reinstalling:
rm -rf node_modules package-lock.json
npm install
npm run compile
GraphDoc is an MIT-licensed open-source project. For issues, bug reports, or feature requests, visit the GitHub repository.

Build docs developers (and LLMs) love