From 59721a3a939d16368bd459a5c6c1e14b4ec75a71 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=96=BB=E5=8B=87=E7=A5=A5?= <237899745@qq.com> Date: Wed, 12 Nov 2025 12:13:53 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E5=A4=8D:=20=E6=9B=B4=E6=AD=A3Python?= =?UTF-8?q?=E9=85=8D=E7=BD=AE=E6=96=B9=E5=BC=8F=EF=BC=8C=E8=A7=A3=E5=86=B3?= =?UTF-8?q?npm=E9=94=99=E8=AF=AF?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 问题: - 使用了错误的命令: 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 --- install.sh | 8 ++------ 1 file changed, 2 insertions(+), 6 deletions(-) diff --git a/install.sh b/install.sh index f69a370..66aabc7 100644 --- a/install.sh +++ b/install.sh @@ -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 "依赖更新失败"