fix(install): npm-cli.js path + CONTRIBUTING/PR template
install.sh: bundled Node 的 INSTALL_NPM 之前指向 bin/npm shell wrapper, 通过 \"node npm\" 调用会失败。改为 lib/node_modules/npm/bin/npm-cli.js, 并加 run_npm() 帮助函数区分系统 Node(用 npm 可执行)和 bundled Node。 install.ps1: 系统 Node 场景下 npm-cli.js 路径推导脆弱。改为按候选路径 依次试探,找不到则直接退到 npm.cmd。 新增 CONTRIBUTING.md + .github/PULL_REQUEST_TEMPLATE.md,规范 PR 流程, 减少空白/无说明 PR(对应 issue PR #36)。 Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
This commit is contained in:
@@ -93,12 +93,18 @@ if ($sysNode) {
|
||||
if ($major -ge 20) {
|
||||
Write-Green " [OK] System Node.js $sysVer found, reusing"
|
||||
$INSTALL_NODE = "node"
|
||||
$npmCmd = (Get-Command npm -ErrorAction SilentlyContinue).Source
|
||||
$npmRoot = Split-Path (Split-Path $npmCmd)
|
||||
$NPM_CLI = "$npmRoot\node_modules\npm\bin\npm-cli.js"
|
||||
if (-not (Test-Path $NPM_CLI)) {
|
||||
$npmPrefix = & node -e "console.log(process.execPath.replace(/[\\\/]node\.exe$/i,''))" 2>$null
|
||||
$NPM_CLI = "$npmPrefix\node_modules\npm\bin\npm-cli.js"
|
||||
# Resolve npm-cli.js next to node.exe; fall back to npm.cmd as a launcher.
|
||||
$nodeExeDir = Split-Path $sysNode.Source -Parent
|
||||
$candidates = @(
|
||||
"$nodeExeDir\node_modules\npm\bin\npm-cli.js",
|
||||
"$env:APPDATA\npm\node_modules\npm\bin\npm-cli.js",
|
||||
"$env:ProgramFiles\nodejs\node_modules\npm\bin\npm-cli.js"
|
||||
)
|
||||
$NPM_CLI = $null
|
||||
foreach ($p in $candidates) { if (Test-Path $p) { $NPM_CLI = $p; break } }
|
||||
if (-not $NPM_CLI) {
|
||||
# Last resort: use npm.cmd directly (don't pass through node.exe)
|
||||
$NPM_CLI = (Get-Command npm -ErrorAction SilentlyContinue).Source
|
||||
}
|
||||
$USE_SYSTEM_NODE = $true
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user