Registry / devops / cmake-ts

cmake-ts

JSON →
library1.0.2jsnpmunverified

cmake-ts v1.0.2 is a CMake-based build system for native Node.js and Electron addons, written in TypeScript. It is loosely inspired by cmake-js but fixes several design flaws, focusing on prebuilt addons and advanced build configurations. It ships TypeScript type definitions and supports cross-compilation for multiple architectures (arm64, x64, etc.) and runtimes (node, electron, iojs). The project is actively maintained with frequent releases on GitHub. Key differentiators include built-in support for cross-compilation via named configs, a manifest system for runtime addon loading, and compatibility with modern Node versions (12+).

npm install cmake-ts
INSTALL
IMPORT
SIG · CMAKE-TS
C
cmake-ts
devopsjavascriptv1.0.2
Install
Import
Disk
Pass rate
0/ 6
Env Coverage0 / 6
glibc
1822
musl
1822
Install & Compatibility
Where this runs
tested against v? · npm install
Install × environment matrix
Each cell = how many times install + import succeeded across repeated harness runs. Partial = flaky.
glibc = Debian/Ubuntu slim · musl = Alpine Linux
musl
node 18226 runs
build_error
glibc
node 18226 runs
build_error
Code
Verified usage

Verified import paths — ran on the pinned version, not inferred.

loadAddon
import { loadAddon } from 'cmake-ts/build/loader.mjs';
const loadAddon = require('cmake-ts/build/loader');
ESM-only; the loader is an .mjs file, not requireable. Available since v0.6.0.
default
import cmakeTs from 'cmake-ts';
const cmakeTs = require('cmake-ts');
Default export is ESM-only; CommonJS require is not supported. Use dynamic import if needed.
type Manifest
import type { Manifest } from 'cmake-ts/build/types';
import { Manifest } from 'cmake-ts';
Manifest type is exported from 'cmake-ts/build/types', not the main entry. Type-only import avoids runtime inclusion.

Shows how to build a native addon with cmake-ts and load it at runtime using the ESM loader. Demonstrates loader usage and CLI build command.

// Build your native addon using cmake-ts CLI // Ensure CMake is installed (https://cmake.org/download) // Create CMakeLists.txt in project root import { loadAddon } from 'cmake-ts/build/loader.mjs'; import path from 'node:path'; import { fileURLToPath } from 'node:url'; const __dirname = path.dirname(fileURLToPath(import.meta.url)); // Load the addon built by cmake-ts // The loader automatically finds the correct binary for current runtime/architecture const addon = loadAddon(path.resolve(__dirname, 'build')); // Use the addon console.log(addon.myNativeFunction()); // Build via CLI: cmake-ts build --config release // Cross-compile: cmake-ts build --config cross-linux-arm64-release
cmake-ts --version
Debug
Known issues
breakingIn v0.6.1, parent directory name changed from 'abi' to 'libc-abi-buildType' to prevent conflicts. If your package hardcodes the old path, it will fail to load.
fix
Use the loader's manifest to resolve paths dynamically instead of hardcoding.
affects: >=0.6.1
breakingIn v0.5.2, cmake-ts started using Vite for building. The legacy and modern bundles are provided. If you rely on internal module internals, your code may break.
fix
Ensure you use the public API and the loader from 'cmake-ts/build/loader.mjs'.
affects: >=0.5.2
deprecatedThe download utility 'downloadZip' was removed in v0.5.3. Use the new download utils instead.
fix
Replace 'downloadZip' calls with the updated download utilities from '@aminya/node-gyp-build' or similar.
affects: >=0.5.3
gotchaThe loader file is in .mjs format, so it cannot be required with require(). This is intentional as it's ESM-only.
fix
Use dynamic import() or switch to an ESM project. If running CommonJS, consider using import('cmake-ts/build/loader.mjs').
affects: >=0.6.0
Errors
Common errors & fixes
Error: Cannot find module 'cmake-ts/build/loader'
Using CommonJS require on an .mjs file.
fix
Use dynamic import: const { loadAddon } = await import('cmake-ts/build/loader.mjs');
AssertionError [ERR_ASSERTION]: The addon was not built for this runtime/architecture
No prebuilt binary matches the current runtime (e.g., node vs electron, or different ABI).
fix
Run `cmake-ts build --config release` to build for the current runtime, or ensure cross-compilation config is correct.
Error: CMake is not installed or not found in PATH
CMake is required but not installed.
fix
Install CMake from https://cmake.org/download/ or use a package manager (apt, brew, choco) and add to PATH.
Error: ENOENT: no such file or directory, open 'manifest.json'
The build directory does not contain a manifest.json (e.g., not built with cmake-ts or old version).
fix
Run `cmake-ts build` to generate the manifest. Ensure you are using cmake-ts v0.6.0+.
Upgrade
Version history
1.0.2latest on npm
Audit
Dependencies
@aminya/node-gyp-buildoptionalUsed for runtime addon loading and prebuild detection
cmakerequiredThe CMake build system is required at build time
Agent activity
5 hits · last 30 days
node
4
Resources
cmake-ts — npm install cmake-ts · libregistry