修复: 更正Python配置方式,解决npm错误

问题:
- 使用了错误的命令: npm config set python python3
- npm报错: 'python' is not a valid npm option
- 导致脚本在安装依赖时直接退出

修复:
- 删除错误的 npm config set python python3 命令
- 改用环境变量方式: PYTHON=python3 npm install --production
- 这是node-gyp官方推荐的方式

测试:
- 环境变量会在npm install执行期间生效
- node-gyp会自动识别PYTHON环境变量
- 不会产生invalid option错误

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <noreply@anthropic.com>
This commit is contained in:
2025-11-12 12:13:53 +08:00
parent ee3c522a37
commit 59721a3a93

View File

@@ -1103,13 +1103,11 @@ install_backend_dependencies() {
npm config set registry https://registry.npmmirror.com
fi
# 设置npm使用Python3
npm config set python python3
print_info "正在安装依赖包包含数据库native模块可能需要几分钟..."
# 安装依赖,捕获错误
if npm install --production; then
if PYTHON=python3 npm install --production; then
print_success "后端依赖安装完成"
else
print_error "依赖安装失败"
@@ -2024,8 +2022,6 @@ update_install_dependencies() {
fi
fi
# 设置npm使用Python3
npm config set python python3
# 清理旧的node_modules
if [[ -d "node_modules" ]]; then
@@ -2035,7 +2031,7 @@ update_install_dependencies() {
print_info "正在重新安装依赖(可能需要几分钟)..."
if npm install --production; then
if PYTHON=python3 npm install --production; then
print_success "依赖更新完成"
else
print_error "依赖更新失败"