DEV Community

Cover image for React Native Environment Info Script for Windows & Mac
PEAKIQ
PEAKIQ

Posted on • Originally published at peakiq.in

React Native Environment Info Script for Windows & Mac

Originally published on PEAKIQ

Source: https://www.peakiq.in/blog/react-native-environment-info-script-for-windows-mac



Get Full Details of Your React Native Environment

When debugging build issues or setting up a new machine, knowing exactly what is installed — and which versions — saves a lot of guesswork. These scripts collect system information, installed binaries, SDKs, IDEs, and npm packages for a React Native environment on both Windows and macOS.


Windows (PowerShell)

How to run

  1. Save the script as react-native-info.ps1
  2. Open PowerShell and navigate to the file location
  3. Allow script execution for the current session and run it:
Set-ExecutionPolicy Unrestricted -Scope Process
.\react-native-info.ps1
Enter fullscreen mode Exit fullscreen mode

Script

# Get System Info
Write-Host "System info`n"

Write-Host "System:"
Write-Host "   OS: $(Get-CimInstance Win32_OperatingSystem | Select-Object -ExpandProperty Caption)"
Write-Host "   CPU: $(Get-CimInstance Win32_Processor | Select-Object -ExpandProperty Name)"
Write-Host "   Memory: $(Get-CimInstance Win32_ComputerSystem | Select-Object -ExpandProperty TotalPhysicalMemory | ForEach-Object { [math]::Round($_ / 1GB, 2) }) GB"
Write-Host "   Shell: PowerShell $($PSVersionTable.PSVersion)"

# Get Installed Binaries
Write-Host "`nBinaries:"
Write-Host "   Node: $(node -v)"
Write-Host "   Yarn: $(yarn -v)"
Write-Host "   npm: $(npm -v)"
$watchmanVersion = (Get-Command watchman -ErrorAction SilentlyContinue) ? (watchman --version) : "Not Found"
Write-Host "   Watchman: $watchmanVersion"

# Get Installed Managers
Write-Host "`nManagers:"
$chocoVersion = (choco -v 2>$null) ? (choco -v) : "Not Installed"
Write-Host "   Chocolatey: $chocoVersion"
$scoopVersion = (scoop -v 2>$null) ? (scoop -v) : "Not Installed"
Write-Host "   Scoop: $scoopVersion"

# Get SDKs
Write-Host "`nSDKs:"
Write-Host "   Android SDK: $(Get-ItemProperty -Path 'HKLM:\SOFTWARE\Android Studio' -ErrorAction SilentlyContinue | Select-Object -ExpandProperty Path)"
Write-Host "   Java: $(java -version 2>&1 | Select-String -Pattern 'version' | ForEach-Object { $_ -replace 'java version "', '' -replace '"', '' })"

# Get Installed IDEs
Write-Host "`nIDEs:"
Write-Host "   Xcode: Not Available on Windows"
$androidStudio = (Get-Command "C:\Program Files\Android\Android Studio\bin\studio64.exe" -ErrorAction SilentlyContinue) ? "Installed" : "Not Installed"
Write-Host "   Android Studio: $androidStudio"

# Get npm package versions
Write-Host "`nnpm Packages:"
$reactNativeCli = npm show @react-native-community/cli version
$reactVersion = npm show react version
$reactNativeVersion = npm show react-native version
Write-Host "   @react-native-community/cli: $reactNativeCli"
Write-Host "   react: $reactVersion"
Write-Host "   react-native: $reactNativeVersion"

Write-Host "`nnpm Global Packages:"
$globalReactNative = npm list -g --depth=0 | Select-String 'react-native' | ForEach-Object { ($_ -split '@')[1] }
Write-Host "   *react-native*: $($globalReactNative -join ', ')"
Enter fullscreen mode Exit fullscreen mode

macOS (Bash)

How to run

  1. Save the script as react-native-info.sh
  2. Make it executable:
chmod +x react-native-info.sh
Enter fullscreen mode Exit fullscreen mode
  1. Run it:
./react-native-info.sh
Enter fullscreen mode Exit fullscreen mode

Script

#!/bin/bash

echo "React Native Environment Info for macOS"

# System Info
echo -e "\nSystem Info:"
echo "   OS: $(sw_vers -productName) $(sw_vers -productVersion)"
echo "   CPU: $(sysctl -n machdep.cpu.brand_string)"
echo "   Memory: $(sysctl -n hw.memsize | awk '{print $1/1073741824 " GB"}')"
echo "   Shell: $SHELL"

# Installed Binaries
echo -e "\nBinaries:"
echo "   Node: $(node -v)"
echo "   Yarn: $(yarn -v)"
echo "   npm: $(npm -v)"
WATCHMAN_VERSION=$(watchman --version 2>/dev/null || echo "Not Found")
echo "   Watchman: $WATCHMAN_VERSION"

# Package Managers
echo -e "\nPackage Managers:"
echo "   Homebrew: $(brew -v | head -n 1)"

# SDKs
echo -e "\nSDKs:"
ANDROID_SDK=${ANDROID_HOME:-"Not Found"}
echo "   Android SDK: $ANDROID_SDK"
echo "   Java: $(java -version 2>&1 | awk -F '"' '/version/ {print $2}')"

# IDEs
echo -e "\nIDEs:"
XCODE_VERSION=$(xcodebuild -version 2>/dev/null || echo "Not Installed")
echo "   Xcode: $XCODE_VERSION"
ANDROID_STUDIO=$(ls /Applications | grep "Android Studio" || echo "Not Installed")
echo "   Android Studio: $ANDROID_STUDIO"

# npm Packages
echo -e "\nnpm Packages:"
echo "   @react-native-community/cli: $(npm show @react-native-community/cli version)"
echo "   react: $(npm show react version)"
echo "   react-native: $(npm show react-native version)"

echo -e "\nnpm Global Packages:"
GLOBAL_REACT_NATIVE=$(npm list -g --depth=0 | grep react-native || echo "Not Installed")
echo "   *react-native*: $GLOBAL_REACT_NATIVE"
Enter fullscreen mode Exit fullscreen mode

What Each Script Collects

Section Details
System OS name, CPU, total memory, shell version
Binaries Node, Yarn, npm, Watchman
Package managers Chocolatey / Scoop (Windows), Homebrew (macOS)
SDKs Android SDK path, Java version
IDEs Xcode (macOS only), Android Studio
npm packages Latest published versions of core RN packages
npm global Globally installed React Native packages

Notes

  • The PowerShell script requires Set-ExecutionPolicy Unrestricted -Scope Process to run unsigned scripts. This only affects the current session and does not change your system policy permanently.
  • The Bash script fixes a minor bug in the original — $ANDROID_HOME now uses ${ANDROID_HOME:-"Not Found"} instead of echo $ANDROID_HOME which would silently print nothing if the variable is unset.
  • The npm show calls fetch the latest published version from the registry, not what is installed locally. To check locally installed versions, use npm list --depth=0 inside your project instead.

Top comments (0)