Skip to content

Commit 27c785a

Browse files
committed
fix(install): improve node-gyp build process with verbose output and fallback
- Add verbose output to node-gyp rebuild for better debugging - Add alternative build approach using configure + build separately - Set MAKEFLAGS to ensure proper directory creation - Remove duplicate code and clean up build process - Fix container build issues with make directory creation
1 parent c48239d commit 27c785a

1 file changed

Lines changed: 23 additions & 13 deletions

File tree

scripts/install.js

Lines changed: 23 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -69,27 +69,37 @@ try {
6969
});
7070
}
7171

72-
// Pre-create the build directory structure to avoid make errors
72+
// Use node-gyp directly to build with verbose output for debugging
73+
const { execSync } = require('child_process');
7374
const baseDir = path.dirname(__dirname);
74-
const buildReleaseDir = path.join(baseDir, 'build/Release');
75-
const buildObjDir = path.join(baseDir, 'build/Release/obj.target/syslog_native/src/native');
76-
77-
console.log('📁 Creating build directory structure...');
78-
mkdirSync(buildReleaseDir, { recursive: true });
79-
mkdirSync(buildObjDir, { recursive: true });
80-
console.log('✅ Build directory structure created');
8175

82-
// Use node-gyp directly to build
83-
const { execSync } = require('child_process');
8476
try {
85-
execSync('npx node-gyp rebuild', {
77+
console.log('🔨 Running node-gyp rebuild with verbose output...');
78+
execSync('npx node-gyp rebuild --verbose', {
8679
cwd: baseDir,
87-
stdio: 'inherit'
80+
stdio: 'inherit',
81+
env: {
82+
...process.env,
83+
// Ensure make creates directories as needed
84+
MAKEFLAGS: '--no-builtin-rules'
85+
}
8886
});
8987
console.log('✅ node-gyp rebuild completed successfully');
9088
} catch (gypError) {
9189
console.error('❌ node-gyp rebuild failed:', gypError.message);
92-
throw gypError;
90+
91+
// Try alternative approach with make directory creation
92+
console.log('🔄 Trying alternative build approach...');
93+
try {
94+
execSync('npx node-gyp configure && npx node-gyp build', {
95+
cwd: baseDir,
96+
stdio: 'inherit'
97+
});
98+
console.log('✅ Alternative build approach completed successfully');
99+
} catch (altError) {
100+
console.error('❌ Alternative build approach also failed:', altError.message);
101+
throw gypError; // Throw original error
102+
}
93103
}
94104

95105
// Get the target path from node-pre-gyp

0 commit comments

Comments
 (0)