Skip to content

Commit 4f105ad

Browse files
committed
fix: correct prebuild binary search paths
1 parent b3e06e9 commit 4f105ad

File tree

1 file changed

+15
-14
lines changed

1 file changed

+15
-14
lines changed

src/index.ts

Lines changed: 15 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -59,30 +59,31 @@ function findNativeModule(): string {
5959
const platform = process.platform;
6060
const arch = process.arch;
6161

62+
// 获取当前模块的根目录(node_modules/wsjtx-lib)
63+
const moduleRoot = path.resolve(__dirname, '..', '..');
64+
6265
const possiblePaths = [
6366
// 1. Prebuilt binaries (npm packages) - highest priority
64-
path.resolve(__dirname, '..', 'prebuilds', `${platform}-${arch}`, 'wsjtx_lib_nodejs.node'),
67+
path.join(moduleRoot, 'prebuilds', `${platform}-${arch}`, 'wsjtx_lib_nodejs.node'),
6568

6669
// 2. GitHub Actions legacy format (for backward compatibility)
67-
path.resolve(__dirname, '..', 'prebuilds', `${platform}-latest-${arch}`, 'wsjtx_lib_nodejs.node'),
68-
path.resolve(__dirname, '..', 'prebuilds', `ubuntu-latest-${arch}`, 'wsjtx_lib_nodejs.node'), // Linux
69-
path.resolve(__dirname, '..', 'prebuilds', `macos-latest-${arch}`, 'wsjtx_lib_nodejs.node'), // macOS
70-
path.resolve(__dirname, '..', 'prebuilds', `windows-latest-${arch}`, 'wsjtx_lib_nodejs.node'), // Windows
70+
path.join(moduleRoot, 'prebuilds', `${platform}-latest-${arch}`, 'wsjtx_lib_nodejs.node'),
71+
path.join(moduleRoot, 'prebuilds', `ubuntu-latest-${arch}`, 'wsjtx_lib_nodejs.node'), // Linux
72+
path.join(moduleRoot, 'prebuilds', `macos-latest-${arch}`, 'wsjtx_lib_nodejs.node'), // macOS
73+
path.join(moduleRoot, 'prebuilds', `windows-latest-${arch}`, 'wsjtx_lib_nodejs.node'), // Windows
7174

7275
// 3. Local development builds - third priority
73-
// From dist/src/ - direct build output
74-
path.resolve(__dirname, '..', '..', 'build', 'wsjtx_lib_nodejs.node'),
75-
// From dist/src/ - Release subdirectory
76-
path.resolve(__dirname, '..', '..', 'build', 'Release', 'wsjtx_lib_nodejs.node'),
77-
78-
// 4. Direct build output (when running from src/)
79-
path.resolve(__dirname, '..', 'build', 'wsjtx_lib_nodejs.node'),
80-
// Release subdirectory (MSVC, cmake default, etc.)
81-
path.resolve(__dirname, '..', 'build', 'Release', 'wsjtx_lib_nodejs.node'),
76+
path.join(moduleRoot, 'build', 'wsjtx_lib_nodejs.node'),
77+
path.join(moduleRoot, 'build', 'Release', 'wsjtx_lib_nodejs.node'),
8278
];
8379

80+
// 添加调试信息
81+
console.log('Searching for native module with paths:');
82+
possiblePaths.forEach(p => console.log(` - ${p}`));
83+
8484
for (const modulePath of possiblePaths) {
8585
if (fs.existsSync(modulePath)) {
86+
console.log(`Found native module at: ${modulePath}`);
8687
return modulePath;
8788
}
8889
}

0 commit comments

Comments
 (0)