# HMS 小程序开发启动脚本 # 用法:右键 → 使用 PowerShell 运行,或在终端中 ./dev.ps1 Write-Host "=== HMS 小程序开发环境 ===" -ForegroundColor Cyan # 1. 提升文件描述符限制 Write-Host "[1/3] 设置文件描述符限制..." -ForegroundColor Yellow try { $current = (Get-ItemProperty -Path "HKLM:\SYSTEM\CurrentControlSet\Control\Session Manager\SubSystems" -Name "Windows" -ErrorAction Stop).Windows Write-Host " 系统文件描述符配置已读取" -ForegroundColor Green } catch { Write-Host " 无法读取系统配置(需要管理员权限)" -ForegroundColor Red } # 2. 清理缓存 Write-Host "[2/3] 清理构建缓存..." -ForegroundColor Yellow if (Test-Path "dist") { Remove-Item -Recurse -Force dist -ErrorAction SilentlyContinue Write-Host " dist 已清理" -ForegroundColor Green } if (Test-Path "node_modules\.cache") { Remove-Item -Recurse -Force node_modules\.cache -ErrorAction SilentlyContinue Write-Host " webpack cache 已清理" -ForegroundColor Green } # 3. 启动开发编译 Write-Host "[3/3] 启动 Taro 开发编译..." -ForegroundColor Yellow Write-Host "" $env:NODE_ENV = "development" npx taro build --type weapp --watch Write-Host "" Write-Host "提示:" -ForegroundColor Cyan Write-Host " - 编译完成后在微信开发者工具中导入 dist 目录" Write-Host " - 如遇到 EMFILE 错误,请重启此脚本" Write-Host " - 建议每 2 小时重启微信开发者工具防止内存泄漏"