Skip to content

Fix: Resolve 'program not found' error for lean-spec ui/mcp commands on Windows#158

Open
GoldTest wants to merge 1 commit intocodervisor:mainfrom
GoldTest:main
Open

Fix: Resolve 'program not found' error for lean-spec ui/mcp commands on Windows#158
GoldTest wants to merge 1 commit intocodervisor:mainfrom
GoldTest:main

Conversation

@GoldTest
Copy link

问题描述

修复Windows用户报告的issue:

  • npm install -g lean-spec (v0.2.28) 后
  • 执行 lean-spec uilean-spec mcp 出现 "program not found" 错误
  • npm install -g @leanspec/ui + npx @leanspec/ui 可以正常工作

环境信息

  • Windows 11
  • npm 10.8.1
  • Node.js v24.11.1
  • lean-spec 0.2.28
  • pnpm 10.32.1

根本原因

  1. 缺失依赖: lean-spec主包没有声明dependencies

    • @leanspec/ui、@leanspec/http-server、@leanspec/mcp未随主包安装
  2. npm v10兼容性: npx命令已废弃,需使用 npm exec

  3. 跨平台问题: Windows上使用'node'字符串而非process.execPath

修复内容

✓ packages/cli/package.json - 添加@leanspec/ui、@leanspec/http-server、@leanspec/mcp
✓ packages/ui/bin/leanspec-ui.js - 使用process.execPath、参数验证、错误消息改进
✓ rust/leanspec-cli/src/commands/ui.rs - npm exec替代npx、单元测试
✓ rust/leanspec-cli/src/commands/mcp.rs - npm exec替代npx、单元测试

验证方法

npm install -g lean-spec@latest
lean-spec ui      # 应该正常启动UI
lean-spec mcp     # 应该正常启动MCP

…on Windows

- Add missing dependencies to lean-spec package (@leanspec/ui, @leanspec/http-server, @leanspec/mcp)
- Improve error handling in leanspec-ui.js: use process.execPath instead of 'node' string for cross-platform compatibility
- Fix npm v10 compatibility: replace deprecated npx with 'npm exec' in ui.rs and mcp.rs
- Add unit tests for npm command generation
- Add validation checks for HTTP server path resolution

This fixes the issue where 'lean-spec ui' and 'lean-spec mcp' commands fail with 'program not found' when installed globally via npm.

Fixes: Windows 11 users reporting npm 10.8.1 + Node v24.11.1 compatibility issues
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant