Socket
Socket
Sign inDemoInstall

node-gyp-build

Package Overview
Dependencies
0
Maintainers
1
Versions
37
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

    node-gyp-build

Build tool and bindings loader for node-gyp that supports prebuilds


Version published
Maintainers
1
Install size
6.83 kB
Created

Package description

What is node-gyp-build?

The node-gyp-build package is designed to simplify the process of compiling and distributing native Node.js addons. It automatically detects the platform and architecture of the user's system and chooses the correct pre-compiled binary to use, if available. If a pre-compiled binary is not available, it falls back to building from source using node-gyp.

What are node-gyp-build's main functionalities?

Loading pre-compiled binaries

This code attempts to load a pre-compiled binary for the native addon located in the same directory as the script. If a pre-compiled binary is not available for the current platform, it will attempt to compile the addon from source.

const nativeAddon = require('node-gyp-build')(__dirname)

Building from source

This code snippet demonstrates how to explicitly get the path to the correct binary and then require it. If the binary does not exist, node-gyp-build will attempt to compile the addon from source using the binding.gyp file located in the __dirname directory.

const path = require('path');
const nodeGypBuild = require('node-gyp-build');

const bindingPath = nodeGypBuild.path(__dirname);
const binding = require(bindingPath);

Other packages similar to node-gyp-build

Readme

Source

node-gyp-build

Build tool and bindings loader for node-gyp that supports prebuilds.

npm install node-gyp-build

Use together with prebuildify to easily support prebuilds for your native modules.

Usage

node-gyp-build works similar to node-gyp build except that it will check if a build or prebuild is present before rebuilding your project.

It's main intended use is as an npm install script and bindings loader for native modules that bundle prebuilds using prebuildify.

First add node-gyp-build as an install script to your native project

{
  ...
  "scripts": {
    "install": "node-gyp-build"
  }
}

Then in your index.js, instead of using the bindings module use node-gyp-build to load your binding.

var binding = require('node-gyp-build')(__dirname)

If you do these two things and bundle prebuilds prebuildify your native module will work for most platforms without having to compile on install time AND will work in both node and electron without the need to recompile between usage.

License

MIT

FAQs

Last updated on 02 Mar 2018

Did you know?

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc