# Production Build Commands for Insomnia from package.json: The Complete Guide

> Discover Insomnia's production build commands from package.json. Learn to compile TypeScript and generate native installers using npm run app build and npm run app package.

- Repository: [Kong/insomnia](https://github.com/Kong/insomnia)
- Tags: how-to-guide
- Published: 2026-06-27

---

**The Kong/insomnia repository defines two primary commands—`npm run app-build` to compile the TypeScript source and bundle assets, and `npm run app-package` to generate native installers using electron-builder.**

The Kong/insomnia project automates its production pipeline through **npm scripts** defined in the root [`package.json`](https://github.com/Kong/insomnia/blob/main/package.json). These commands wrap complex build steps, including React Router compilation, TypeScript transpilation, and Electron packaging, to produce distributable binaries for macOS, Linux, and Windows. Understanding these production build commands is essential for developers who need to create release-ready binaries from the source code.

## Primary Production Build Commands

### Build the Application with npm run app-build

The `npm run app-build` command initiates the compilation phase of the pipeline. According to the root [`package.json`](https://github.com/Kong/insomnia/blob/main/package.json), this script executes `npm run build -w insomnia`, which invokes the build process defined in [`packages/insomnia/package.json`](https://github.com/Kong/insomnia/blob/main/packages/insomnia/package.json).

This step runs `react-router build` followed by the custom [`scripts/build.ts`](https://github.com/Kong/insomnia/blob/main/scripts/build.ts) script. The output is a production-ready `/build` directory containing the minified [`entry.main.min.js`](https://github.com/Kong/insomnia/blob/main/entry.main.min.js) file and all static assets required for the Electron application.

### Create Installers with npm run app-package

The `npm run app-package` command transforms compiled assets into native installers. This script first ensures a fresh build, then invokes **electron-builder** using the configuration defined in [`packages/insomnia/electron-builder.config.js`](https://github.com/Kong/insomnia/blob/main/packages/insomnia/electron-builder.config.js).

The process generates platform-specific distributables—including DMG and ZIP for macOS, AppImage and DEB for Linux, and NSIS installers for Windows—placing them in the `./dist` directory. The [`electron-builder.config.js`](https://github.com/Kong/insomnia/blob/main/electron-builder.config.js) file controls signing options, target formats, and extra resources like the bundled [`yarn-standalone.js`](https://github.com/Kong/insomnia/blob/main/yarn-standalone.js).

### Windows-Specific Distribution

For Windows-specific releases, use the `npm run package:windows:dist` command. This specialized script creates a signed NSIS installer optimized for Windows distribution, handling platform-specific signing requirements and packaging conventions that differ from the cross-platform `app-package` command.

Run the complete production pipeline using these commands:

```bash

# Compile TypeScript and bundle assets

npm run app-build

# Create native installers for all platforms

npm run app-package

# Create signed Windows installer only

npm run package:windows:dist

```

## How the Build Pipeline Works

### Step 1: TypeScript and React Compilation

The build process begins with **TypeScript and React compilation** orchestrated by [`packages/insomnia/scripts/build.ts`](https://github.com/Kong/insomnia/blob/main/packages/insomnia/scripts/build.ts). This script invokes `react-router build` to handle the frontend assets, then compiles TypeScript source files using ESBuild. The result is a tree-shaken bundle containing the minified [`entry.main.min.js`](https://github.com/Kong/insomnia/blob/main/entry.main.min.js) referenced by the `extraMetadata` field in the Electron Builder configuration.

### Step 2: Electron Entry Point Generation

The [`packages/insomnia/scripts/esbuild.entrypoints.ts`](https://github.com/Kong/insomnia/blob/main/packages/insomnia/scripts/esbuild.entrypoints.ts) script generates the critical Electron entry-point files. It bundles the main process and preload scripts that Electron requires to start the application, outputting them to the build directory alongside the React assets.

### Step 3: Electron Builder Packaging

During the final phase, **electron-builder** reads [`packages/insomnia/electron-builder.config.js`](https://github.com/Kong/insomnia/blob/main/packages/insomnia/electron-builder.config.js) to create native installers. This configuration file defines target platforms, code signing certificates, and extra metadata. The builder packages the compiled files from the `build` directory into distributable formats ready for deployment.

## Critical Configuration Files

Several key files control the production build process:

- **[`package.json`](https://github.com/Kong/insomnia/blob/main/package.json)** (repository root): Exposes the high-level `app-build` and `app-package` scripts that orchestrate the build pipeline.

- **[`packages/insomnia/package.json`](https://github.com/Kong/insomnia/blob/main/packages/insomnia/package.json)**: Defines the lower-level `build` and `package` scripts used by the root-level wrappers, including the workspace-specific build commands.

- **[`packages/insomnia/electron-builder.config.js`](https://github.com/Kong/insomnia/blob/main/packages/insomnia/electron-builder.config.js)**: Configures Electron Builder with target platforms (DMG, ZIP, AppImage, DEB, NSIS), signing options, and extra resources.

- **[`packages/insomnia/scripts/build.ts`](https://github.com/Kong/insomnia/blob/main/packages/insomnia/scripts/build.ts)**: Orchestrates the React Router build, TypeScript compilation, and asset copying into the output directory.

- **[`packages/insomnia/scripts/esbuild.entrypoints.ts`](https://github.com/Kong/insomnia/blob/main/packages/insomnia/scripts/esbuild.entrypoints.ts)**: Generates the bundled Electron entry-point files that serve as the application's main and preload scripts.

## Summary

- Use **`npm run app-build`** to compile TypeScript, bundle the React UI, and create the `/build` directory with [`entry.main.min.js`](https://github.com/Kong/insomnia/blob/main/entry.main.min.js) and static assets.

- Use **`npm run app-package`** to generate native installers for all supported platforms using the configuration in [`electron-builder.config.js`](https://github.com/Kong/insomnia/blob/main/electron-builder.config.js).

- Use **`npm run package:windows:dist`** specifically for signed Windows NSIS installers.

- The build pipeline relies on [`packages/insomnia/scripts/build.ts`](https://github.com/Kong/insomnia/blob/main/packages/insomnia/scripts/build.ts) for compilation and [`packages/insomnia/electron-builder.config.js`](https://github.com/Kong/insomnia/blob/main/packages/insomnia/electron-builder.config.js) for packaging configuration.

- No manual webpack or electron commands are required—the npm scripts handle the entire production workflow.

## Frequently Asked Questions

### What is the difference between app-build and app-package?

The `app-build` command compiles the source code and prepares the `/build` directory containing the minified JavaScript and assets, while `app-package` takes those compiled files and creates the actual native installers (DMG, EXE, AppImage, etc.) using electron-builder. You must run `app-build` before `app-package`, though the latter typically ensures a fresh build automatically.

### Where are the compiled build artifacts located?

After running `npm run app-build`, the compiled artifacts reside in `packages/insomnia/build`, including the [`entry.main.min.js`](https://github.com/Kong/insomnia/blob/main/entry.main.min.js) file and static assets. After running `npm run app-package`, the final distributable installers appear in the `./dist` directory at the repository root.

### How do I create a Windows-specific installer?

Run the **`npm run package:windows:dist`** command to generate a signed Windows NSIS installer. This command uses platform-specific configuration in [`packages/insomnia/electron-builder.config.js`](https://github.com/Kong/insomnia/blob/main/packages/insomnia/electron-builder.config.js) to handle Windows signing requirements and produce a distributable executable suitable for direct distribution.

### Which file controls the electron-builder configuration?

The **[`packages/insomnia/electron-builder.config.js`](https://github.com/Kong/insomnia/blob/main/packages/insomnia/electron-builder.config.js)** file contains all electron-builder settings, including target platforms (DMG, ZIP, AppImage, DEB, NSIS), code signing configurations, extra resources, and the `extraMetadata` field that references the compiled [`entry.main.min.js`](https://github.com/Kong/insomnia/blob/main/entry.main.min.js) file.