@aminya/node-gyp-build

中文文档
4.8.1-aminya.1发布于 2024/06/14MITCommonJS零依赖近 30 天下载 1.5万

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

原始使用文档
文档目录3 节
  1. Usage
  2. Supported prebuild names
  3. License

node-gyp-build

Fork created because of https://github.com/prebuild/node-gyp-build/pull/55

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

npm install node-gyp-build

Test

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

Usage

Note. Prebuild names have changed in prebuildify@3 and node-gyp-build@4. Please see the documentation below.

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 with 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.

Users can override node-gyp-build and force compiling by doing npm install --build-from-source.

Prebuilds will be attempted loaded from MODULE_PATH/prebuilds/... and then next EXEC_PATH/prebuilds/... (the latter allowing use with zeit/pkg)

Supported prebuild names

If so desired you can bundle more specific flavors, for example musl builds to support Alpine, or targeting a numbered ARM architecture version.

These prebuilds can be bundled in addition to generic prebuilds; node-gyp-build will try to find the most specific flavor first. Prebuild filenames are composed of tags. The runtime tag takes precedence, as does an abi tag over napi. For more details on tags, please see prebuildify.

Values for the libc and armv tags are auto-detected but can be overridden through the LIBC and ARM_VERSION environment variables, respectively.

License

MIT

版本与发布记录

@aminya/node-gyp-build 共发布 6 个版本,首次发布于 2022/11/27;过去 12 个月发布了 0 个版本。

版本发布日期距今
4.8.1-aminya.1latest2024/06/142 年前
4.5.0-aminya.52023/11/212 年前
4.5.0-aminya.42022/11/283 年前
4.5.0-aminya.32022/11/273 年前
4.5.0-aminya.22022/11/273 年前
4.5.0-aminya.12022/11/273 年前

关于 @aminya/node-gyp-build 的常见问题

@aminya/node-gyp-build 是什么?

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

如何安装 @aminya/node-gyp-build?

在项目目录运行 npm install @aminya/node-gyp-build,或使用 pnpm add / yarn add / bun add。它还提供命令行工具 aminya-node-gyp-build、aminya-node-gyp-build-optional、aminya-node-gyp-build-test,可以用 npx aminya-node-gyp-build 直接运行。

@aminya/node-gyp-build 支持 TypeScript 吗?

该包的 package.json 没有声明类型入口。需要类型提示时,可以在 npm 上查找社区维护的 @types/aminya__node-gyp-build 是否存在。

@aminya/node-gyp-build 支持 ESM 还是 CommonJS?

以 CommonJS 形式发布,可以直接 require();在 ES Module 项目中也可以用 import 引入(Node.js 会把 module.exports 作为默认导出)。

@aminya/node-gyp-build 可以商用吗?

@aminya/node-gyp-build 使用 MIT 许可。宽松许可:允许商业使用、修改和再分发,通常只需在分发时保留原版权与许可声明。以上为概括,不构成法律意见,请以许可原文为准。

@aminya/node-gyp-build 的下载量有多少?

根据 npm 官方下载统计,@aminya/node-gyp-build 在 2026/10/06 – 2026/11/04 这 30 天内被下载 14,705 次,日均约 490 次。下载量会把 CI 构建、镜像同步和作为其他包依赖的安装一并计入,适合横向比较热度,不能直接等同于使用人数。

@aminya/node-gyp-build 还在维护吗?

最新版本 4.8.1-aminya.1 发布于 2024/06/14(2 年前);至今共发布 6 个版本,其中过去 12 个月发布了 0 个;首次发布于 2022/11/27。发布频率只是参考信号:功能稳定的工具可能很少需要更新,建议结合源码仓库的 issue 和提交记录判断。