Repository navigation
fix(windows): run vcpkg only when the prebuilt binary is unavailable - #52
Merged
Merged
Conversation
aborovsky
commented
Nov 26, 2026
The preinstall hook ran scripts/vcpkg-setup.js unconditionally on Windows, so every npm install built curl and nine dependencies from source (20-30 minutes, needs git and Visual Studio) before node-pre-gyp downloaded the prebuilt binary that made that build unnecessary. scripts/install.js replaces the preinstall and install hooks. On Windows it tries the prebuilt download first and runs vcpkg plus the fallback build only when the download fails. Explicit source builds (npm_config_build_from_source) and git checkouts still set up vcpkg first, so CI builds and local `pnpm pregyp rebuild` keep working. Other platforms are unchanged. A new windows-consumer-install job installs the packed tarball with npm and fails if vcpkg ran or the install takes longer than 15 minutes.
A failed extraction can leave a partial lib/binding/node_libcurl.node. A second `node-pre-gyp install` treats any file at that path as installed and skips the build, so npm could finish with a corrupt addon. Use --build-from-source, whose rebuild deletes module_path before compiling.
aborovsky
force-pushed
the
fix/windows-skip-vcpkg-when-prebuilt
branch
from
November 26, 2026 20:50
a8486cb to
72895dd
Compare
This was referenced Nov 27, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Problem
npm install @brightsec/node-libcurlon Windows takes 20-30 minutes. Thepreinstallhook runsscripts/vcpkg-setup.jsunconditionally on win32: it clones vcpkg and builds curl, OpenSSL, libssh2, ngtcp2, nghttp3, nghttp2, gsasl, brotli and c-ares from source (each twice,-dbgand-rel). Only then doesinstall(node-pre-gyp install --fallback-to-build) download the prebuilt Windows binary, which is published for every release (for examplenode_libcurl-v5.1.6-node-v137-win32-x64-unknown.tar.gz) and makes that build unnecessary. Consumers also need git and Visual Studio installed for an install that ends up using the prebuilt binary anyway.In bright-cli this costs about 20 minutes in each Windows job of the release pipeline:
npm citook 20m33s while building the Windows executable, and 23-29 minutes in every Windows smoke/e2e job.Change
scripts/install.jsreplaces thepreinstallandinstallhooks:node-pre-gyp installdownload-only. If it succeeds, stop. If not, runvcpkg-setup.jsand thennode-pre-gyp install --build-from-source. A source rebuild deleteslib/bindingfirst, so a partial binary left by a failed extraction is never accepted as installed.npm_config_build_from_source=true(or the package name), or a git checkout: run vcpkg first, as before. CI builds (build.ps1,thread-sanitizer, the Electron consumer job) set the flag, and localpnpm pregyp rebuildin a checkout still finds vcpkg ready.node-pre-gyp install --fallback-to-build.The download-only attempt drops
npm_config_fallback_to_buildfrom its env, because node-pre-gyp letsnpm_config_*override argv and a build without vcpkg would fail.Verification
test/scripts/install.spec.tscovers each branch above.New
windows-consumer-install / npm-prebuilt-installjob: packs the branch, installs it with npm into a fresh project onwindows-latest, loads the addon, and fails if%LOCALAPPDATA%\node-libcurl-vcpkgexists or the job takes over 15 minutes. It needs Windows prebuilts for the version inpackage.json, so it fails on a version that has not finished publishing binaries yet.Local (macOS): packed the branch as 5.1.6 and installed it with npm;
scripts/install.jsdownloaded the prebuilt binary and the addon loaded.windows-latest(run):npm installof the packed branch finished in 7s using the v5.2.0-1 prebuilt, with no vcpkg directory created. An earlier run of the same job, started before the v5.2.0-1 Windows binaries were published, got a 404 for the prebuilt, printed the fallback message and started vcpkg, which confirms the fallback path.