init-windows fails silently with "unknown command" when pwsh.exe is missing; not documented in rnw-dependencies
维护者通常 2 天内回复
还没有人认领这个 Issue。
评估
- 难度
- 4/5
- 预计耗时
- 3-5 天
- 新手友好度
- 48/100
- Issue 类型
- 缺陷
- 描述清晰度
- 基本清楚
- 活跃度
- 冷清
- 技术栈
- node.js, powershell, react-native
- 领域
- cli, documentation, tooling
调研方向
使用 npx react-native init-windows --overwrite 重现该失败,然后检查 react-native-windows/react-native.config.js 以及 @react-native-windows/find-dotnet-tools 的加载路径。检查 rnw-dependencies 页面和包依赖元数据,以确认缺失的 PowerShell 和 runtime-package 要求。选定的修复方案已针对报告的 0.81.x 和 0.83.x 行为完成验证,即表示完成。
由索引模型根据 Issue 内容生成。
描述
Problem Description
On a fresh project, npx react-native init-windows --overwrite fails with:
error: unknown command 'init-windows'
The actual root cause is that react-native-windows's plugin throws at module-load time inside @react-native-windows/find-dotnet-tools when pwsh.exe is not on PATH:
Unable to find pwsh.exe. It should have been made available by `yarn install`.
The community CLI silently swallows the throw during plugin discovery, drops the command, and reports "unknown command" instead of the real error.
PowerShell 7 is not listed on the rnw-dependencies page. Windows ships only Windows PowerShell 5.1 by default, so most fresh machines fail this check.
This affects both [email protected] and 0.83.x. Additionally, the 0.83.x line has a missing-dependency bug: @react-native-windows/find-dotnet-tools is not in any package's dependencies but is required at runtime. Even after installing pwsh, init-windows still fails on 0.83.x until the user runs yarn add @react-native-windows/find-dotnet-tools manually.
Steps To Reproduce
On a clean Windows 11 install without pwsh.exe on PATH:
npx --yes @react-native-community/cli@latest init Test --version 0.83-stablecd Test && yarn add react-native-windows@^0.83.0npx react-native init-windows --overwrite
Result: error: unknown command 'init-windows'
To see the real underlying error, run:
node -e "require('react-native-windows/react-native.config.js')"
`Unable to find pwsh.exe. It should have been made available by yarn install.`
Expected Results
Either:
init-windowsplugin discovery is resilient to missing pwsh: defer the pwsh check until the command actually runs, so the user sees a clear "install PowerShell 7" message instead of "unknown command".- PowerShell 7 is documented as a prerequisite on the rnw-dependencies page, so users install it before reaching this step.
@react-native-windows/find-dotnet-toolsis added toreact-native-windows's (or@react-native-windows/cli's)dependenciesso it's installed transitively rather than left as a manualyarn add.
Ideally all three.
CLI version
20.0.0
Environment
System:
OS: Windows 11 10.0.26200
CPU: (20) x64 13th Gen Intel(R) Core(TM) i9-13900H
Memory: 39.55 GB / 63.45 GB
Binaries:
Node:
version: 22.23.0
path: C:\Program Files\nodejs\node.EXE
Yarn:
version: 1.22.22
path: C:\Program Files\nodejs\yarn.CMD
npm:
version: 10.9.8
path: C:\Program Files\nodejs\npm.CMD
Watchman: Not Found
SDKs:
Android SDK: Not Found
Windows SDK:
AllowDevelopmentWithoutDevLicense: Enabled
AllowAllTrustedApps: Enabled
Versions:
- 10.0.19041.0
- 10.0.22621.0
- 10.0.26100.0
IDEs:
Android Studio: AI-243.24978.46.2431.13363775
Visual Studio:
- 17.14.36401.2 (Visual Studio Enterprise 2022)
Languages:
Java:
version: 17.0.13
path: C:\Program Files\Eclipse Adoptium\jdk-17.0.13.11-hotspot\bin\javac.EXE
Ruby: Not Found
npmPackages:
"@react-native-community/cli":
installed: 20.0.0
wanted: 20.0.0
react:
installed: 19.1.4
wanted: 19.1.4
react-native:
installed: 0.81.6
wanted: 0.81.6
react-native-windows:
installed: 0.81.29
wanted: ~0.81.6
npmGlobalPackages:
"*react-native*": Not Found
Android:
hermesEnabled: true
newArchEnabled: true
iOS:
hermesEnabled: Not found
newArchEnabled: Not found
Community Modules
None
Target React Native Architecture
Old Architecture (UWP) Only
Target Platform Version
10.0.22621
Visual Studio Version
None
Build Configuration
None
Snack, code example, screenshot, or link to a repository
No response
- 主要语言
- C++
- 星标
- 17.4k
- 派生
- 1.2k
- 平均合并
- 2 天 17 小时
- 30 天内合并 PR
- 13
环境准备
- 没有 Dockerfile 或 Docker Compose 文件
- 有 Pull Request 模板
- 阅读贡献指南
从这里开始
- 先读完整个 Issue,再读项目的贡献指南。
- 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
- Fork 仓库,在一个分支上完成修改。
- 提交 Pull Request,并在描述里引用这个 Issue 编号。
microsoft/react-native-windows 的其他 Issue
-
Needs: Triage :mag:
难度 2/5 1-3 小时 新手友好度 82/100
microsoft/react-native-windows#16340 ·
维护者通常 2 天内回复
-
bug Needs: Triage :mag:
难度 2/5 1-3 小时 新手友好度 68/100
microsoft/react-native-windows#16321 · 1 条评论 ·
维护者通常 2 天内回复
-
Needs: Triage :mag:
难度 5/5 一周以上 新手友好度 30/100
microsoft/react-native-windows#16442 · 1 条评论 ·
维护者通常 2 天内回复
-
Fabric: activating the window doesn't announce the window or the focused control to a screen reader未关闭Needs: Triage :mag:
难度 4/5 3-5 天 新手友好度 48/100
microsoft/react-native-windows#16435 ·
维护者通常 2 天内回复
-
bug Needs: Triage :mag:
难度 4/5 3-5 天 新手友好度 48/100
microsoft/react-native-windows#16410 ·
维护者通常 2 天内回复
查看 microsoft/react-native-windows 的全部 Issue
相似的 Issue
-
难度 2/5 1 小时以内 新手友好度 72/100
ashhart/TensorFold#535 ·
维护者通常 1 天内回复
-
难度 2/5 1-3 小时 新手友好度 66/100
维护者通常 1 天内回复
-
难度 2/5 1-3 小时 新手友好度 72/100
维护者通常 1 天内回复
-
agent:Windows bug
难度 2/5 1-3 小时 新手友好度 62/100
维护者通常 1 天内回复
-
难度 2/5 1-3 小时 新手友好度 72/100
维护者通常 1 天内回复