Registry / devops / cmake-js

cmake-js

JSON →
library8.0.0jsnpmunverified

CMake.js is a Node.js native addon build tool that replaces node-gyp's gyp with CMake. Current stable version is 8.0.0 (released late 2024), requiring Node.js >=20.17.0 or >=22.9.0. It supports Node.js, NW.js, and Electron runtimes out of the box, with automatic runtime detection and build configuration. Key differentiators: uses CMake instead of GYP, supports modern Node.js versions, built-in fetch for smaller install size, and native addon development without post-build steps for Electron/NW.js. Release cadence is irregular with major version bumps roughly every 1-2 years, each introducing breaking changes.

npm install cmake-js
INSTALL
IMPORT
SIG · CMAKE-JS
C
cmake-js
devopsjavascriptv8.0.0
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.

default (cmake-js CLI)
npx cmake-js build
node -e "require('cmake-js')"
cmake-js is primarily used as a CLI tool, not a library import. Use npx or install globally.
CMakeJS (programmatic API)
const cmakejs = require('cmake-js');
import cmakejs from 'cmake-js';
cmake-js is CommonJS-only. ESM import is not supported.

Shows minimal setup: CMakeLists.txt with cmake-js include hook, and CLI compile command.

// Create a minimal CMakeLists.txt in your project root: // cmake_minimum_required(VERSION 3.10) // project(MyNativeAddon) // include(../node_modules/cmake-js/cmake-js.cmake) // Then build: // npx cmake-js compile // Example package.json build script: // { "scripts": { "build": "cmake-js compile" } }
cmake-js --version
Debug
Known issues
breakingv8.0.0 dropped support for Node.js <20.17.0 and <22.9.0
fix
Upgrade Node.js to ^20.17.0 || >=22.9.0
affects: <8.0.0
breakingv7.0.0 removed support for Node.js <14.15
fix
Use v6.x for older Node.js or upgrade Node.js to 14.15+
affects: >=7.0.0 <8.0.0
breakingv7.0.0 changed CMake variable naming conventions - CMAKE_JS_SRC etc. require updates to CMakeLists.txt
fix
Update CMakeLists.txt to use new variable names as per upgrade guide
affects: >=7.0.0
breakingv4.0.0 removed support for Visual Studio 2013 and older
fix
Use Visual Studio 2015 or newer
affects: >=4.0.0
gotchaCross-compilation requires manual CMAKE_TOOLCHAIN_FILE specification
fix
Use --cmake-path or -DCMAKE_TOOLCHAIN_FILE=... when targeting different architecture
affects: *
gotchaElectron builds require --runtime=electron --runtime-version=X.Y.Z flags to match Electron's Node.js ABI
fix
Use: cmake-js compile --runtime=electron --runtimeVersion=28.0.0
affects: *
Errors
Common errors & fixes
CMake Error: Could not find cmake module file: cmake-js.cmake
CMakeLists.txt missing include line or cmake-js not installed
fix
Add 'include(../node_modules/cmake-js/cmake-js.cmake)' to CMakeLists.txt, or run 'npm install cmake-js'
Error: Unable to detect runtime. Use --runtime and --runtime-version.
cmake-js cannot auto-detect runtime from Node.js version
fix
Specify runtime explicitly: --runtime=node --runtime-version=20.0.0
npm ERR! command cmake-js compile failed (exit code 1)
Missing CMake installation or incompatible generator
fix
Install CMake >=3.10 and ensure generator matches platform (e.g., 'Unix Makefiles' on Linux, 'Visual Studio 17 2022' on Windows)
Upgrade
Version history
8.0.0latest on npm
Audit
Dependencies
cmakerequiredRequired build tool - CMake.js requires CMake to be installed on the system
Agent activity
7 hits · last 30 days
node
4
Resources