Skip to content

Commit 2ce5e79

Browse files
committed
fix(install): use npx node-gyp for reliable native compilation
- Replace node-pre-gyp rebuild with direct npx node-gyp rebuild - Ensures node-gyp is available and builds correctly in container environment - Fixes issue where build directory was not being created - Maintains proper error handling and binary copying workflow
1 parent b516d35 commit 2ce5e79

1 file changed

Lines changed: 18 additions & 5 deletions

File tree

scripts/install.js

Lines changed: 18 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -55,13 +55,21 @@ try {
5555
console.log('📝 Error details:', error.message);
5656

5757
try {
58-
// Fallback to building from source using node-pre-gyp
58+
// Fallback to building from source using node-gyp directly
5959
console.log('🔨 Building native addon from source...');
60-
const runner = new npg.Run({ package_json_path });
61-
runner.parseArgv(['rebuild']);
6260

63-
// Use node-pre-gyp to install the binary to the correct location
64-
console.log('📦 Installing built binary to target location...');
61+
// Use node-gyp directly to build
62+
const { execSync } = require('child_process');
63+
try {
64+
execSync('npx node-gyp rebuild', {
65+
cwd: path.dirname(__dirname),
66+
stdio: 'inherit'
67+
});
68+
console.log('✅ node-gyp rebuild completed successfully');
69+
} catch (gypError) {
70+
console.error('❌ node-gyp rebuild failed:', gypError.message);
71+
throw gypError;
72+
}
6573

6674
// Get the target path from node-pre-gyp
6775
const targetPath = npg.find(package_json_path);
@@ -72,6 +80,11 @@ try {
7280

7381
// Copy the binary from build directory
7482
const builtBinary = path.join(__dirname, '../build/Release/syslog_native.node');
83+
84+
if (!existsSync(builtBinary)) {
85+
throw new Error(`Built binary not found at ${builtBinary}`);
86+
}
87+
7588
copyFileSync(builtBinary, targetPath);
7689
console.log('✅ Copied binary to:', targetPath);
7790

0 commit comments

Comments
 (0)