feat(windows): Improve Windows compatibility for npx installation

- Add cross-platform Deno installation in install.js using PowerShell
- Move native dependencies (better-sqlite3, diskusage, node-pty) to optionalDependencies
- Add preinstall warning for Windows npm users recommending pnpm
- Enables npx installation to work on Windows environments

This addresses the root cause of npx installation failures on Windows
and provides graceful fallbacks for optional native dependencies.
This commit is contained in:
Alexx_FTW committed 2025-07-28 00:55:44 +01:00
1 parent 17c23cc444
commit 488aaeae2f
2 files changed
+37 -23

No files matched your search

+6 -3
View File
@@ -7,6 +7,7 @@
"claude-flow": "./bin/claude-flow"
},
"scripts": {
"preinstall": "node -e \"if(process.platform === 'win32' && process.env.npm_config_user_agent && process.env.npm_config_user_agent.includes('npm')) { console.warn('⚠️ Warning: On Windows, it is recommended to use pnpm to install this package to avoid potential native dependency build issues.'); console.warn('💡 Try: pnpm install or pnpx claude-flow@alpha'); }\"",
"dev": "tsx src/cli/main.ts",
"build": "npm run clean && npm run update-version && npm run build:esm && npm run build:cjs && npm run build:binary",
"update-version": "node scripts/update-bin-version.js",
@@ -105,13 +106,11 @@
"dependencies": {
"@modelcontextprotocol/sdk": "^1.0.4",
"@types/better-sqlite3": "^7.6.13",
"better-sqlite3": "^12.2.0",
"blessed": "^0.1.81",
"chalk": "^4.1.2",
"cli-table3": "^0.6.3",
"commander": "^11.1.0",
"cors": "^2.8.5",
"diskusage": "^1.1.3",
"express": "^4.18.2",
"figlet": "^1.8.1",
"fs-extra": "^11.2.0",
@@ -120,12 +119,16 @@
"helmet": "^7.1.0",
"inquirer": "^9.2.12",
"nanoid": "^5.0.4",
"node-pty": "^1.0.0",
"ora": "^7.0.1",
"p-queue": "^8.1.0",
"ruv-swarm": "^1.0.14",
"ws": "^8.18.3"
},
"optionalDependencies": {
"better-sqlite3": "^12.2.0",
"diskusage": "^1.1.3",
"node-pty": "^1.0.0"
},
"devDependencies": {
"@babel/core": "^7.28.0",
"@babel/plugin-syntax-import-attributes": "^7.27.1",
+31 -20
View File
@@ -4,7 +4,7 @@ import os from 'node:os';
import path from 'node:path';
import fs from 'node:fs';
import https from 'node:https';
import { spawn } from 'node:child_process';
import { spawn, exec } from 'node:child_process';
console.log('Installing Claude-Flow...');
@@ -26,28 +26,39 @@ async function installDeno() {
console.log('Deno not found. Installing Deno...');
const platform = os.platform();
const arch = os.arch();
if (platform === 'win32') {
console.log('Please install Deno manually from https://deno.land/');
process.exit(1);
}
return new Promise((resolve, reject) => {
const installScript = spawn('curl', ['-fsSL', 'https://deno.land/x/install/install.sh'], { stdio: 'pipe' });
const sh = spawn('sh', [], { stdio: ['pipe', 'inherit', 'inherit'] });
installScript.stdout.pipe(sh.stdin);
sh.on('close', (code) => {
if (code === 0) {
console.log('Deno installed successfully!');
resolve();
} else {
reject(new Error('Failed to install Deno'));
}
return new Promise((resolve, reject) => {
console.log('Installing Deno on Windows using PowerShell...');
const psCommand = `powershell -Command "irm https://deno.land/install.ps1 | iex"`;
exec(psCommand, (error, stdout, stderr) => {
if (error) {
console.error('Failed to install Deno with PowerShell:', stderr);
console.log('Please install Deno manually from https://deno.land/');
reject(new Error('Failed to install Deno'));
} else {
console.log('Deno installed successfully!');
resolve();
}
});
});
});
} else {
return new Promise((resolve, reject) => {
const installScript = spawn('curl', ['-fsSL', 'https://deno.land/x/install/install.sh'], { stdio: 'pipe' });
const sh = spawn('sh', [], { stdio: ['pipe', 'inherit', 'inherit'] });
installScript.stdout.pipe(sh.stdin);
sh.on('close', (code) => {
if (code === 0) {
console.log('Deno installed successfully!');
resolve();
} else {
reject(new Error('Failed to install Deno'));
}
});
});
}
}
// Main installation process