{"id":18223,"library":"cmake-js","title":"CMake.js","description":"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.","status":"active","version":"8.0.0","language":"javascript","source_language":"en","source_url":"git://github.com/cmake-js/cmake-js","tags":["javascript","native","addon","module","c","c++","bindings","build","buildtools"],"install":[{"cmd":"npm install cmake-js","lang":"bash","label":"npm"},{"cmd":"yarn add cmake-js","lang":"bash","label":"yarn"},{"cmd":"pnpm add cmake-js","lang":"bash","label":"pnpm"}],"dependencies":[{"reason":"Required build tool - CMake.js requires CMake to be installed on the system","package":"cmake","optional":false}],"imports":[{"note":"cmake-js is primarily used as a CLI tool, not a library import. Use npx or install globally.","wrong":"node -e \"require('cmake-js')\"","symbol":"default (cmake-js CLI)","correct":"npx cmake-js build"},{"note":"cmake-js is CommonJS-only. ESM import is not supported.","wrong":"import cmakejs from 'cmake-js';","symbol":"CMakeJS (programmatic API)","correct":"const cmakejs = require('cmake-js');"}],"quickstart":{"code":"// Create a minimal CMakeLists.txt in your project root:\n// cmake_minimum_required(VERSION 3.10)\n// project(MyNativeAddon)\n// include(../node_modules/cmake-js/cmake-js.cmake)\n\n// Then build:\n// npx cmake-js compile\n\n// Example package.json build script:\n// { \"scripts\": { \"build\": \"cmake-js compile\" } }","lang":"javascript","description":"Shows minimal setup: CMakeLists.txt with cmake-js include hook, and CLI compile command."},"warnings":[{"fix":"Upgrade Node.js to ^20.17.0 || >=22.9.0","message":"v8.0.0 dropped support for Node.js <20.17.0 and <22.9.0","severity":"breaking","affected_versions":"<8.0.0"},{"fix":"Use v6.x for older Node.js or upgrade Node.js to 14.15+","message":"v7.0.0 removed support for Node.js <14.15","severity":"breaking","affected_versions":">=7.0.0 <8.0.0"},{"fix":"Update CMakeLists.txt to use new variable names as per upgrade guide","message":"v7.0.0 changed CMake variable naming conventions - CMAKE_JS_SRC etc. require updates to CMakeLists.txt","severity":"breaking","affected_versions":">=7.0.0"},{"fix":"Use Visual Studio 2015 or newer","message":"v4.0.0 removed support for Visual Studio 2013 and older","severity":"breaking","affected_versions":">=4.0.0"},{"fix":"Use --cmake-path or -DCMAKE_TOOLCHAIN_FILE=... when targeting different architecture","message":"Cross-compilation requires manual CMAKE_TOOLCHAIN_FILE specification","severity":"gotcha","affected_versions":"*"},{"fix":"Use: cmake-js compile --runtime=electron --runtimeVersion=28.0.0","message":"Electron builds require --runtime=electron --runtime-version=X.Y.Z flags to match Electron's Node.js ABI","severity":"gotcha","affected_versions":"*"}],"env_vars":null,"search_vec":"'-2':91 '1':90 '20.17.0':29 '2024':26 '22.9.0':31 '8.0.0':23 'addon':7,71,99 'automat':44 'bind':103 'box':42 'break':95 'build':8,48,76,104 'buildtool':105 'built':62 'built-in':61 'bump':87 'c':101,102 'cadenc':81 'chang':96 'cmake':18,53 'cmake.js':1,2 'configur':49 'current':19 'detect':46 'develop':72 'differenti':51 'electron':37 'electron/nw.js':79 'everi':89 'fetch':64 'gyp':14,16,56 'instal':67 'instead':54 'introduc':94 'irregular':83 'javascript':97 'key':50 'late':25 'major':85 'modern':58 'modul':100 'nativ':6,70,98 'node':13 'node-gyp':12 'node.js':5,28,34,59 'nw.js':35 'post':75 'post-build':74 'releas':24,80 'replac':11 'requir':27 'rough':88 'runtim':38,45 'size':68 'smaller':66 'stabl':20 'step':77 'support':33,57 'tool':9 'use':52 'version':21,60,86 'without':73 'year':92","created_at":"2026-04-25T07:37:07.456584+00:00","updated_at":"2026-04-25T07:37:07.456584+00:00","problems":[{"fix":"Add 'include(../node_modules/cmake-js/cmake-js.cmake)' to CMakeLists.txt, or run 'npm install cmake-js'","cause":"CMakeLists.txt missing include line or cmake-js not installed","error":"CMake Error: Could not find cmake module file: cmake-js.cmake"},{"fix":"Specify runtime explicitly: --runtime=node --runtime-version=20.0.0","cause":"cmake-js cannot auto-detect runtime from Node.js version","error":"Error: Unable to detect runtime. Use --runtime and --runtime-version."},{"fix":"Install CMake >=3.10 and ensure generator matches platform (e.g., 'Unix Makefiles' on Linux, 'Visual Studio 17 2022' on Windows)","cause":"Missing CMake installation or incompatible generator","error":"npm ERR! command cmake-js compile failed (exit code 1)"}],"ecosystem":"npm","meta_description":null,"install_score":null,"quickstart_score":null,"quickstart_tag":null,"pypi_latest":null,"cli_name":"cmake-js","cli_version":null,"type":"library","homepage":null,"github":"https://github.com/cmake-js/cmake-js","docs":null,"changelog":null,"pypi":null,"npm":"https://www.npmjs.com/package/cmake-js","openapi_spec":null,"status_page":null,"smithery":null,"categories":["devops"],"base_url":null,"auth_type":null,"provenance":{"verified_status":null,"verified_at":null,"last_verified":"2026-06-17","next_check":"2026-07-24","install_tag":null}}