Skip to content

node-gyp

A command-line tool that compiles C/C++ native addons for Node.js.

Stars
10.7k
Forks
1.9k
Licence
MIT
Language
Python
Last update
8 days ago
Type
Dev tool

What it is

node-gyp is a command-line tool, written in Node.js, that compiles native addons, which are modules written in C or C++ that Node.js can load. It bundles a copy of the gyp-next build project and downloads the Node.js header files needed for the version you target. It is not used to build Node.js itself.

  • Run node-gyp configure and node-gyp build in a folder containing a binding.gyp file to produce a .node binding
  • Target a specific Node.js version's headers with the install and list commands
  • Pass --dist-url or --nodedir to build an addon against Electron headers

Great for

  • Developers publishing or installing Node.js packages that include native C/C++ code
  • Maintainers who need one build command to work across Unix, macOS and Windows
  • Developers building addons for a specific Node.js version or a third-party runtime such as Electron

Not ideal for

  • Projects that contain only JavaScript, since no native compilation is needed
  • People trying to build Node.js itself, which the README says node-gyp is not used for
  • Developers who cannot install a C/C++ toolchain and Python, since both are required
Step-by-step guide: how to use node-gypInstall, first run, examples, tips and FAQs

How to get it

  1. 1

    Install with a package manager

    You'll need: Python (a version supported by node-gyp, see the Python devguide) · make and a C/C++ compiler toolchain (GCC, clang, or Visual Studio C++ tools on Windows) · Node.js with npm

    Install node-gyp globally with npm

    npm install -g node-gyp

    Windows only: install Python and Visual C++ tools via Chocolatey

    choco install python visualstudio2026-workload-vctools -y
  2. 2

    Run it

    • Install node-gyp and its prerequisites for your operating system.
    • Change into your addon's root directory, which must contain a binding.gyp file.
    • Run node-gyp configure to generate the build files.
    • Run node-gyp build to compile; the output appears in build/Release/ or build/Debug/.
  3. 3

    Get the most out of it

    • Use --python or the npm_config_python environment variable if you have several Python versions installed
    • Use --debug (or -d) with configure, build or rebuild to produce a Debug build
    • Use --dist-url or --nodedir when building for runtimes such as Electron
    • Install the VSSetup PowerShell module on Windows to make Visual Studio detection more reliable, as the README advises

Downloads

Strengths

  • One set of commands works across the supported platforms, according to the README
  • Supports all current and LTS Node.js target versions, per the README
  • Widely used in the Node.js ecosystem, with about 10.7k GitHub stars

Trade-offs

  • Requires a supported Python version plus a working C/C++ compiler, which can be hard to set up on Windows
  • Auto-detection of older Visual Studio versions can fail and needs manual flags
  • Python 3.12 and later require node-gyp v10 or newer, as noted in the README

How it compares

ProjectStarsTypeLevelUpdatedBest for
node-gyp (this)10.7kDev toolintermediate8 days agoDevelopers publishing or installing Node.js packages that include native C/C++ code
nodemon26.7kDev toolbeginner4 days agoNode.js developers running a web server locally who want fast edit-and-reload cycles
nvm95.7kDev toolbeginner8 days agoDevelopers who work on several Node.js projects that need different versions
pnpm37kDev toolbeginner4 days agoDevelopers working in Node.js projects who want faster installs and less disk use
asdf25.6kDev toolbeginner5 days agoDevelopers who work on several projects that need different language versions
validator.js23.7kLibrarybeginner2 months agoJavaScript developers validating form or API input on Node.js

Stats synced from GitHub. The assessment above was drafted with AI from the project's README on 2026-10-29 and may miss recent changes — check the README before relying on a command. MIT licence: free to use, modify and distribute, including commercially, as long as you keep the copyright notice.