You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

Yeoman SharePoint Generator执行后,如何让PowerShell无需交互自动继续?

解决Yeoman SharePoint Generator执行后脚本停滞的问题

Yeoman在完成SPFx项目创建后会停留在完成界面等待用户按键,以下几种方法可以实现无交互自动继续脚本执行:

方法1:启用Yeoman的CI模式(推荐)

Yeoman支持CI(持续集成)环境模式,当检测到CI环境变量为true时,会跳过所有交互式提示,包括最后的按键等待。在执行Yeoman命令前设置该环境变量即可:

$env:CI = "true"
yo @microsoft/sharepoint --component-type "webpart" --component-name $componentName --solution-name $solutionName --framework "react" --skip-install

方法2:通过管道模拟用户回车

向Yeoman进程的标准输入传递一个空行,模拟用户按下回车键,触发进程结束:

Write-Output "" | yo @microsoft/sharepoint --component-type "webpart" --component-name $componentName --solution-name $solutionName --framework "react" --skip-install

方法3:用Start-Process重定向输入

使用PowerShell的Start-Process命令,将进程的标准输入重定向到空设备,让Yeoman无输入可等待,自动结束:

Start-Process -FilePath "yo" -ArgumentList "@microsoft/sharepoint --component-type `"webpart`" --component-name $componentName --solution-name $solutionName --framework `"react`" --skip-install" -NoNewWindow -Wait -RedirectStandardInput "NUL"

内容的提问来源于stack exchange,提问作者Grobanix

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.06.12 16:19:55