claude-flow 2.7.41 → 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,35 +33,79 @@ async function tryLoadSQLite() {
33
33
  return true;
34
34
  } catch (importErr) {
35
35
  loadError = importErr;
36
-
37
- // Check for specific Windows errors
38
- if (requireErr.message.includes('was compiled against a different Node.js version') ||
39
- requireErr.message.includes('Could not locate the bindings file') ||
40
- requireErr.message.includes('The specified module could not be found') ||
36
+
37
+ // Check for NODE_MODULE_VERSION mismatch (different Node.js ABI)
38
+ const isVersionMismatch =
39
+ requireErr.message?.includes('NODE_MODULE_VERSION') ||
40
+ importErr.message?.includes('NODE_MODULE_VERSION') ||
41
+ requireErr.message?.includes('was compiled against a different Node.js version') ||
42
+ importErr.message?.includes('was compiled against a different Node.js version');
43
+
44
+ if (isVersionMismatch) {
45
+ // Extract version info for helpful message
46
+ const errorMsg = requireErr.message || importErr.message || '';
47
+ const compiledMatch = errorMsg.match(/NODE_MODULE_VERSION (\d+)/);
48
+ const requiredMatch = errorMsg.match(/requires\s+NODE_MODULE_VERSION (\d+)/);
49
+
50
+ const nodeVersionMap = {
51
+ '108': '18.x', '115': '20.x', '120': '21.x', '127': '22.x', '131': '23.x'
52
+ };
53
+
54
+ let versionInfo = '';
55
+ if (compiledMatch && requiredMatch) {
56
+ const compiled = nodeVersionMap[compiledMatch[1]] || `ABI ${compiledMatch[1]}`;
57
+ const required = nodeVersionMap[requiredMatch[1]] || `ABI ${requiredMatch[1]}`;
58
+ versionInfo = `\n║ Module compiled for Node.js ${compiled}, running Node.js ${required}`.padEnd(79) + '║';
59
+ }
60
+
61
+ console.warn(`
62
+ ╔══════════════════════════════════════════════════════════════════════════════╗
63
+ ║ Native Module Version Mismatch (NODE_MODULE_VERSION) ║
64
+ ╠══════════════════════════════════════════════════════════════════════════════╣
65
+ ║ ║
66
+ ║ The better-sqlite3 module was compiled for a different Node.js version. ║${versionInfo}
67
+ ║ ║
68
+ ║ Claude Flow will continue with JSON fallback storage (still works fine). ║
69
+ ║ ║
70
+ ║ To fix this and use SQLite: ║
71
+ ║ ║
72
+ ║ Option 1 - Rebuild the module: ║
73
+ ║ > npm rebuild better-sqlite3 ║
74
+ ║ ║
75
+ ║ Option 2 - Clear npx cache (if using npx): ║
76
+ ║ > rm -rf ~/.npm/_npx/ && npx claude-flow@alpha ... ║
77
+ ║ ║
78
+ ║ Option 3 - Reinstall dependencies: ║
79
+ ║ > rm -rf node_modules && npm install ║
80
+ ║ ║
81
+ ╚══════════════════════════════════════════════════════════════════════════════╝
82
+ `);
83
+ return false;
84
+ }
85
+
86
+ // Check for other Windows/installation errors
87
+ if (requireErr.message?.includes('Could not locate the bindings file') ||
88
+ requireErr.message?.includes('The specified module could not be found') ||
41
89
  requireErr.code === 'MODULE_NOT_FOUND') {
42
-
90
+
43
91
  console.warn(`
44
92
  ╔══════════════════════════════════════════════════════════════════════════════╗
45
- Windows SQLite Installation Issue
93
+ ║ SQLite Native Module Installation Issue
46
94
  ╠══════════════════════════════════════════════════════════════════════════════╣
47
95
  ║ ║
48
96
  ║ The native SQLite module failed to load. This is common on Windows when ║
49
- ║ using 'npx' or when node-gyp build tools are not available.
50
- ║ ║
51
- ║ Claude Flow will continue with in-memory storage (non-persistent). ║
97
+ ║ using 'npx' or when node-gyp build tools are not available.
52
98
  ║ ║
53
- To enable persistent storage on Windows:
99
+ Claude Flow will continue with JSON fallback storage (still works fine).
54
100
  ║ ║
55
- Option 1 - Install Windows Build Tools:
56
- ║ > npm install --global windows-build-tools ║
57
- ║ > npm install claude-flow@alpha ║
101
+ To enable SQLite storage:
58
102
  ║ ║
59
- ║ Option 2 - Use Pre-built Binaries:
60
- ║ > npm config set python python3
61
- ║ > npm install claude-flow@alpha --build-from-source=false
103
+ ║ Option 1 - Install Build Tools (Windows):
104
+ ║ > npm install --global windows-build-tools
105
+ ║ > npm install claude-flow@alpha
62
106
  ║ ║
63
- ║ Option 3 - Use WSL (Windows Subsystem for Linux):
64
- ║ Install WSL and run Claude Flow inside a Linux environment
107
+ ║ Option 2 - Use WSL (Windows Subsystem for Linux):
108
+ ║ Install WSL and run Claude Flow inside a Linux environment
65
109
  ║ ║
66
110
  ╚══════════════════════════════════════════════════════════════════════════════╝
67
111
  `);
@@ -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,