claude-flow 2.7.42 → 2.7.43

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -33,6 +33,52 @@ export function isNpmCacheError(error: any): boolean {
33
33
  ) || errorStr.includes('better-sqlite3');
34
34
  }
35
35
 
36
+ /**
37
+ * Detect if an error is a native module version mismatch (NODE_MODULE_VERSION)
38
+ * This happens when native modules are compiled for a different Node.js version
39
+ */
40
+ export function isNativeModuleVersionError(error: any): boolean {
41
+ const errorStr = error?.message || String(error);
42
+ return (
43
+ errorStr.includes('NODE_MODULE_VERSION') ||
44
+ errorStr.includes('was compiled against a different Node.js version') ||
45
+ errorStr.includes('re-compiling or re-installing the module')
46
+ );
47
+ }
48
+
49
+ /**
50
+ * Get helpful message for native module version mismatch
51
+ */
52
+ export function getNativeModuleRecoveryMessage(error: any): string {
53
+ const errorStr = error?.message || String(error);
54
+
55
+ // Extract version numbers if available
56
+ const compiledMatch = errorStr.match(/NODE_MODULE_VERSION (\d+)/);
57
+ const requiredMatch = errorStr.match(/requires\s+NODE_MODULE_VERSION (\d+)/);
58
+
59
+ let message = '⚠️ Native module version mismatch detected.\n';
60
+
61
+ if (compiledMatch && requiredMatch) {
62
+ const nodeVersionMap: Record<string, string> = {
63
+ '108': '18.x',
64
+ '115': '20.x',
65
+ '120': '21.x',
66
+ '127': '22.x',
67
+ '131': '23.x'
68
+ };
69
+ const compiled = nodeVersionMap[compiledMatch[1]] || `ABI ${compiledMatch[1]}`;
70
+ const required = nodeVersionMap[requiredMatch[1]] || `ABI ${requiredMatch[1]}`;
71
+ message += ` Module was compiled for Node.js ${compiled}, but running Node.js ${required}.\n`;
72
+ }
73
+
74
+ message += '\n To fix this, try one of:\n';
75
+ message += ' 1. npm rebuild better-sqlite3\n';
76
+ message += ' 2. rm -rf node_modules && npm install\n';
77
+ message += ' 3. npx cache: rm -rf ~/.npm/_npx/ && run command again\n';
78
+
79
+ return message;
80
+ }
81
+
36
82
  /**
37
83
  * Detect if running on WSL (Windows Subsystem for Linux)
38
84
  */
@@ -315,6 +361,8 @@ export async function recoverInitErrors(error: any): Promise<RecoveryResult> {
315
361
  */
316
362
  export const errorRecovery = {
317
363
  isNpmCacheError,
364
+ isNativeModuleVersionError,
365
+ getNativeModuleRecoveryMessage,
318
366
  isWSL,
319
367
  cleanNpmCache,
320
368
  retryWithRecovery,