node-gyp-build
node-gyp-build copied to clipboard
"No native build was found" for `node-gyp-build` when bundling with `esbuild`
I've started bundling my code with esbuild, but some of my dependencies use node-gyp-build
. These two don't seem to play well together at the moment. I can successfully bundle the code with esbuild, but things break at runtime.
At runtime, the code that uses node-gyp-build
throws an error that says: Error: No native build was found for platform=linux arch=x64 runtime=node abi=93 uv=1 libc=glibc node=16.16.0
. It looks like that message comes from here.
The error stack also references dependencies including sodium-native, sodium-universal and others. But I believe the problem stems from node-gyp-build.
Is this something that can be addressed here? I don't understand the actual issue, and can't find much help online for it. So any clarity on this would be wonderful.
esbuild settings (if that's helpful):
- platform: node
- target: node16
- bundle: true
Related to https://github.com/prebuild/node-gyp-build/issues/22?
This issue seems a bit old, but since I stumbled here as well while searching for a fix I will leave my findings. I was having the exact same issue with the same dependencies, after some time I was able to fix it by adding the following esbuild config:
platform: "node",
packages: "external",
entryPoints: ['path/to/index.ts'],
packages: "external",
This tells ESBuild to treat all of your NPM dependencies as external dependencies, i.e. not to bundle them. This is fine if your goal with ESBuild is not bundling but just (maybe) minifying your own code or something along those lines, but still means you can't use it as a bundler for anything that uses node-gyp-build
.