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