> ## Documentation Index
> Fetch the complete documentation index at: https://invariant-cad.mintlify.site/llms.txt
> Use this file to discover all available pages before exploring further.

# Installation

> Install InvariantCAD and prepare Node.js, browser, and package-manager environments.

## Requirements

* Node.js 22.13 or newer for server-side use and repository tooling
* An ESM-capable project
* A modern browser with WebAssembly for client-side evaluation
* TypeScript is recommended but not required by consumers

InvariantCAD is ESM-only. CommonJS `require("invariantcad")` is not a supported
entry path.

## Add the package

<CodeGroup>
  ```bash pnpm theme={"system"}
  pnpm add invariantcad
  ```

  ```bash npm theme={"system"}
  npm install invariantcad
  ```

  ```bash yarn theme={"system"}
  yarn add invariantcad
  ```

  ```bash bun theme={"system"}
  bun add invariantcad
  ```
</CodeGroup>

The package includes the TypeScript declarations, declaration maps, bundled
Manifold JavaScript/WebAssembly runtime, and the stock `occt-wasm` dependency.
The optional InvariantCAD-owned OCCT facade is not downloaded implicitly and is
not part of the 0.1 npm package.

## Confirm ESM configuration

For Node.js, use an ESM source file (`.mjs`) or mark the consuming package as
ESM:

```json package.json theme={"system"}
{
  "type": "module"
}
```

Then verify a default-kernel import:

```ts theme={"system"}
import { createEvaluator, design, mm, vec3 } from "invariantcad";

const cad = design("parametric-box");
const width = cad.parameter.length("width", mm(40), { min: mm(1) });

const body = cad.box("body", {
  size: vec3(width, mm(20), mm(5)),
  center: true,
});
cad.output("body", body);

async function evaluateParametricBox() {
  const evaluator = await createEvaluator();
  try {
    const result = await evaluator.evaluate(cad.build(), {
      parameters: { width: 60 },
      outputs: ["body"],
    });
    if (!result.ok) {
      throw new Error(
        result.diagnostics.map((item) => item.message).join("\n"),
      );
    }

    try {
      const output = result.value.output("body");
      return {
        volume: output.measure().volume,
        stlBytes: output.export("stl").byteLength,
      };
    } finally {
      result.value.dispose();
    }
  } finally {
    evaluator.dispose();
  }
}

export const parametricBoxSummary = await evaluateParametricBox();
console.log(parametricBoxSummary);
```

## TypeScript settings

InvariantCAD targets modern ESM and works best with a modern module resolver:

```json tsconfig.json theme={"system"}
{
  "compilerOptions": {
    "target": "ES2022",
    "module": "NodeNext",
    "moduleResolution": "NodeNext",
    "strict": true,
    "skipLibCheck": false
  }
}
```

Bundler-based applications can use `module: "ESNext"` and
`moduleResolution: "Bundler"` instead.

## WebAssembly assets

The default Manifold runtime is bundled with InvariantCAD. In a normal Vite or
similar production build, the runtime resolves its sibling WASM asset through
`import.meta.url`. If an environment rewrites asset URLs, pass the final URL:

```ts theme={"system"}
const evaluator = await createEvaluator({
  manifold: { wasmUrl: "/assets/manifold.wasm" },
});
```

The Manifold module is initialized once per JavaScript realm. A later request
cannot change the configured URL after initialization.

OCCT has a larger separate runtime and additional initialization forms. Follow
the [OpenCascade guide](/evaluation/open-cascade) for Node, browser, and custom
facade setup.

## Package-manager install scripts

Some strict package-manager configurations block dependency build scripts. The
stock OCCT and browser toolchains may require explicitly allowing their
documented runtime preparation. Do not enable arbitrary install scripts
globally; scope any exception to the package that requires it and keep the
lockfile reviewed.

<Warning>
  Never copy a WASM file from an unrelated version. JavaScript glue and WASM
  binaries are a matched pair. A mismatch can fail during initialization or,
  for native facade extensions, violate the advertised ABI.
</Warning>

## Next step

Build and export a parameterized model in the [quickstart](/get-started/quickstart).
