|
|
@@ -546,11 +546,26 @@ export async function installNodejs(
|
|
|
|
|
|
checkCancelled()
|
|
|
|
|
|
- // pnpm 安装后也需要使用完整路径
|
|
|
- const pnpmCmd = getPnpmPath()
|
|
|
+ // 获取刷新后的 PATH,确保能找到刚安装的 pnpm
|
|
|
+ const { getRefreshedPath } = await import('./utils')
|
|
|
+ const refreshedPath = await getRefreshedPath()
|
|
|
+ const execEnv = { ...process.env, PATH: refreshedPath }
|
|
|
+
|
|
|
+ // 运行 pnpm setup 配置全局 bin 目录
|
|
|
+ onStatus('nodejs', `${STATUS_MESSAGES.CONFIGURING} pnpm 全局目录...`, 88)
|
|
|
+ try {
|
|
|
+ await execa('pnpm', ['setup'], { env: execEnv, shell: platform === 'win32' })
|
|
|
+ logger.installInfo('pnpm setup 完成')
|
|
|
+ } catch (error) {
|
|
|
+ logger.installWarn('pnpm setup 失败', error)
|
|
|
+ }
|
|
|
+
|
|
|
+ checkCancelled()
|
|
|
+
|
|
|
+ // 配置 pnpm 镜像
|
|
|
onStatus('nodejs', `${STATUS_MESSAGES.CONFIGURING} pnpm 镜像...`, 95)
|
|
|
try {
|
|
|
- await executeCommand(pnpmCmd, ['config', 'set', 'registry', NPM_REGISTRY], false)
|
|
|
+ await execa('pnpm', ['config', 'set', 'registry', NPM_REGISTRY], { env: execEnv, shell: platform === 'win32' })
|
|
|
} catch (error) {
|
|
|
logger.installWarn('配置 pnpm 镜像失败', error)
|
|
|
}
|
|
|
@@ -587,11 +602,26 @@ export async function installNodejs(
|
|
|
|
|
|
checkCancelled()
|
|
|
|
|
|
- // pnpm 安装后也需要使用完整路径
|
|
|
- const pnpmCmd = getPnpmPath()
|
|
|
+ // 获取刷新后的 PATH,确保能找到刚安装的 pnpm
|
|
|
+ const { getRefreshedPath } = await import('./utils')
|
|
|
+ const refreshedPath = await getRefreshedPath()
|
|
|
+ const execEnv = { ...process.env, PATH: refreshedPath }
|
|
|
+
|
|
|
+ // 运行 pnpm setup 配置全局 bin 目录
|
|
|
+ onStatus('nodejs', `${STATUS_MESSAGES.CONFIGURING} pnpm 全局目录...`, 82)
|
|
|
+ try {
|
|
|
+ await execa('pnpm', ['setup'], { env: execEnv })
|
|
|
+ logger.installInfo('pnpm setup 完成')
|
|
|
+ } catch (error) {
|
|
|
+ logger.installWarn('pnpm setup 失败', error)
|
|
|
+ }
|
|
|
+
|
|
|
+ checkCancelled()
|
|
|
+
|
|
|
+ // 配置 pnpm 镜像
|
|
|
onStatus('nodejs', `${STATUS_MESSAGES.CONFIGURING} pnpm 镜像...`, 90)
|
|
|
try {
|
|
|
- await executeCommand(pnpmCmd, ['config', 'set', 'registry', NPM_REGISTRY], false)
|
|
|
+ await execa('pnpm', ['config', 'set', 'registry', NPM_REGISTRY], { env: execEnv })
|
|
|
} catch (error) {
|
|
|
logger.installWarn('配置 pnpm 镜像失败', error)
|
|
|
}
|
|
|
@@ -912,10 +942,22 @@ export async function installAll(options: InstallOptions, onStatus: StatusCallba
|
|
|
onStatus('all', `${STATUS_MESSAGES.INSTALLING} pnpm...`, getProgress())
|
|
|
await executeCommand(npmCmd, ['install', '-g', 'pnpm'], true)
|
|
|
|
|
|
- // pnpm 安装后也需要使用完整路径
|
|
|
- const pnpmCmd = getPnpmPath()
|
|
|
+ // 获取刷新后的 PATH,确保能找到刚安装的 pnpm
|
|
|
+ const { getRefreshedPath } = await import('./utils')
|
|
|
+ const refreshedPath = await getRefreshedPath()
|
|
|
+ const execEnv = { ...process.env, PATH: refreshedPath }
|
|
|
+
|
|
|
+ // 运行 pnpm setup 配置全局 bin 目录
|
|
|
+ try {
|
|
|
+ await execa('pnpm', ['setup'], { env: execEnv, shell: platform === 'win32' })
|
|
|
+ logger.installInfo('pnpm setup 完成')
|
|
|
+ } catch (error) {
|
|
|
+ logger.installWarn('pnpm setup 失败', error)
|
|
|
+ }
|
|
|
+
|
|
|
+ // 配置 pnpm 镜像
|
|
|
try {
|
|
|
- await executeCommand(pnpmCmd, ['config', 'set', 'registry', NPM_REGISTRY], false)
|
|
|
+ await execa('pnpm', ['config', 'set', 'registry', NPM_REGISTRY], { env: execEnv, shell: platform === 'win32' })
|
|
|
} catch (error) {
|
|
|
logger.installWarn('配置 pnpm 镜像失败', error)
|
|
|
}
|