microsoft / microsoft/react-native-windows

init-windows fails silently with "unknown command" when pwsh.exe is missing; not documented in rnw-dependencies

Open
#16,274 0 comments 4 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

bug Needs: Triage :mag:
Dominant language
C++
Stars
17.3k
Forks
1.2k
Avg merge
1d 13h
Merged PRs (30d)
33

Description

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 react-native-windows@0.81.x 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:

  1. npx --yes @react-native-community/cli@latest init Test --version 0.83-stable
  2. cd Test && yarn add react-native-windows@^0.83.0
  3. npx 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:

  1. init-windows plugin 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".
  2. PowerShell 7 is documented as a prerequisite on the rnw-dependencies page, so users install it before reaching this step.
  3. @react-native-windows/find-dotnet-tools is added to react-native-windows's (or @react-native-windows/cli's) dependencies so it's installed transitively rather than left as a manual yarn 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

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Reproduce the failure with npx react-native init-windows --overwrite, then inspect react-native-windows/react-native.config.js and the @react-native-windows/find-dotnet-tools loading path. Check the rnw-dependencies page and package dependency metadata for the missing PowerShell and runtime-package requirements. Done means the selected fix is verified against the reported 0.81.x and 0.83.x behavior.

Written by the indexing model from the issue text.

Assessment

Tech stack
node.js, powershell, react-native
Domain
cli, documentation, tooling
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Quiet
Clarity
Mostly clear
Newbie friendliness
48/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.