# How to Build OpenWork from Source: Complete Build Instructions

> Learn how to build OpenWork from source. Follow these complete instructions to clone the repo, install dependencies, and compile the monorepo for your project.

- Repository: [Different AI/openwork](https://github.com/different-ai/openwork)
- Tags: how-to-guide
- Published: 2026-08-07

---

**To build OpenWork, clone the repository, install dependencies with `pnpm install`, and run `pnpm build` from the root to compile the monorepo using the orchestration script at `scripts/build.mjs`.**

OpenWork is a **pnpm-workspace monorepo** that bundles a desktop Electron client, web UI, and server-side components. Understanding the exact build instructions for OpenWork requires navigating the root [`package.json`](https://github.com/different-ai/openwork/blob/main/package.json) scripts and the Node.js orchestration logic that drives the compilation process.

## Prerequisites

Before compiling, ensure your environment meets the toolchain requirements defined in the repository.

- **Node.js** and **pnpm**: The project uses `pnpm@11` for workspace management. Install it globally:

```bash
npm install -g pnpm

```

- **Source Code**: Clone the `different-ai/openwork` repository and checkout the active development branch:

```bash
git clone https://github.com/different-ai/openwork.git
cd openwork
git checkout dev

```

## Install Workspace Dependencies

OpenWork uses pnpm workspaces to link internal packages. Run the install command from the repository root to symlink all interdependencies across `packages/*`:

```bash
pnpm install

```

This creates the workspace graph required for the build scripts to resolve internal modules like `@openwork/app` and `@openwork/desktop`.

## Run the Production Build

The primary build instructions for OpenWork are encapsulated in the root [[`package.json`](https://github.com/different-ai/openwork/blob/main/package.json)](https://github.com/different-ai/openwork/blob/dev/package.json) script entry `"build": "node scripts/build.mjs"`.

Execute the full monorepo build:

```bash
pnpm build

```

### What the Build Script Does

The [`scripts/build.mjs`](https://github.com/different-ai/openwork/blob/dev/scripts/build.mjs) file orchestrates the compilation pipeline:

1. **TypeScript Compilation**: Runs `tsc` to type-check the core packages.
2. **UI Bundling**: Invokes Vite to bundle the web assets.
3. **Asset Copying**: Moves static files to the distribution directories.

This single entry point ensures consistent build artifacts across desktop and web targets.

## Build Specific Packages

For targeted compilation, use pnpm's `--filter` flag to build individual workspace members without triggering the entire monorepo pipeline.

### Desktop Client Only

```bash
pnpm --filter @openwork/desktop build

```

### Web UI Only

The shortcut script `build:ui` aliases the filter command for the main application package:

```bash
pnpm build:ui

```

This executes `pnpm --filter @openwork/app build` as defined in the root [`package.json`](https://github.com/different-ai/openwork/blob/main/package.json).

### Enterprise Components

Build specific enterprise edition packages:

```bash
pnpm --filter @openwork-ee/den-web build

```

## Development Builds

For active development with hot-reloading, use the `dev` script instead of the production build.

```bash
pnpm dev

```

This command sets `OPENWORK_DEV_MODE=1` and launches the desktop client with automatic port selection for the Chrome DevTools Protocol (CDP). Internally, it resolves to:

```bash
OPENWORK_DEV_MODE=1 pnpm --filter @openwork/desktop dev

```

You can customize the development profile using environment variables:

```bash
OPENWORK_DEV_PROFILE=my-feature OPENWORK_ELECTRON_REMOTE_DEBUG_PORT=0 PORT=0 pnpm dev

```

## Verification and Preview

After a successful build, verify the output by serving the built UI:

```bash
pnpm preview

```

This starts a preview server using the production bundle, allowing you to validate the build before deployment.

## Summary

- **Install**: Use `pnpm install` to initialize the workspace dependencies.
- **Build**: Run `pnpm build` to execute the orchestration script at `scripts/build.mjs`, which handles TypeScript compilation and Vite bundling.
- **Filter**: Use `pnpm --filter <package-name> build` for targeted package builds, or `pnpm build:ui` for the web application only.
- **Develop**: Launch `pnpm dev` for hot-reloading development with `OPENWORK_DEV_MODE` enabled.
- **Verify**: Execute `pnpm preview` to test the production build locally.

## Frequently Asked Questions

### What package manager does OpenWork require?

OpenWork requires **pnpm**. The build scripts and workspace configuration rely on pnpm-specific features like workspace filtering and hoisting. Using npm or yarn will fail to resolve internal workspace dependencies.

### How do I build only the desktop application?

Run `pnpm --filter @openwork/desktop build`. This command targets only the desktop package within the monorepo, skipping the web UI and server components for faster iteration during desktop-specific development.

### Can I run OpenWork in development mode without building first?

Yes. Execute `pnpm dev` from the root. This command sets `OPENWORK_DEV_MODE=1` and launches the Electron client with hot-reloading enabled, bypassing the production build step while providing immediate feedback on code changes.

### Where is the build logic defined?

The main build logic resides in [`scripts/build.mjs`](https://github.com/different-ai/openwork/blob/dev/scripts/build.mjs). This Node.js script coordinates TypeScript compilation, Vite bundling, and asset management across the monorepo, invoked automatically when you run `pnpm build`.