LinuxCommandLibrary

node-gyp

TLDR

Configure project

$ node-gyp configure
copy
Build native addon
$ node-gyp build
copy
Clean build files
$ node-gyp clean
copy
Rebuild (clean + configure + build)
$ node-gyp rebuild
copy
Install Node.js headers
$ node-gyp install
copy
Specify Node.js version
$ node-gyp rebuild --target=[18.0.0]
copy

SYNOPSIS

node-gyp command [options]

DESCRIPTION

node-gyp is a cross-platform build tool for compiling Node.js native addon modules. It uses GYP (Generate Your Projects) to create platform-specific build files.
node-gyp requires Python and a C++ compiler (like gcc, clang, or MSVC).

PARAMETERS

configure

Generate build files.
build
Build native addon.
clean
Remove build directory.
rebuild
Full rebuild.
install
Install Node.js headers.
--target version
Node.js version.
--debug
Debug build.
--arch arch
Target architecture.

BINDING.GYP

$ {
  "targets": [{
    "target_name": "addon",
    "sources": ["src/addon.cc"],
    "include_dirs": [
      "<!(node -p \"require('node-addon-api').include\")"
    ]
  }]
}
copy

CAVEATS

Requires Python 3.x. Needs C++ build tools. Different requirements per OS. May need --python flag.

HISTORY

node-gyp was created by Nathan Rajlich (TooTallNate) to simplify building native Node.js addons across platforms.

SEE ALSO

npm(1), node(1), cmake-js(1)

Copied to clipboard