Ir al contenido

React Native and Expo Environment with PNPM

Professional configuration of the React Native development environment using Expo CLI and the PNPM package manager for iOS and Android.

0views

This guide details the standard technical procedure for preparing a professional development environment for React Native using Expo and the PNPM dependency manager. It covers everything from system prerequisites to the initialization and local deployment of a modern project with cross-platform support (iOS and Android).


Currently, official React documentation and the technical community recommend the combination of Expo and PNPM as the absolute standard working environment:

  • Expo Router: File-based routing (similar to Next.js/Astro) that is fully integrated and typed.
  • PNPM (Performant NPM): Resolves the serious historical issues of NPM's slowness and vulnerability through an architecture based on hard links (hard links) and content-addressable storage.
  • EAS Build/Submit: Cloud compilation of native binaries (.apk, .aab, .ipa) without the need for expensive local hardware.

Before initializing any application, it is essential to have the following tools installed on the system:

  • Node.js (LTS): The active Long-Term Support version is recommended.
  • Package Manager: pnpm (Installed globally via npm i -g pnpm or corepack enable).
  • Git: For project version control.
  1. JDK (Java Development Kit): Install OpenJDK 17 or higher.
  2. Android Studio: Install Android Studio and configure:
    • Android SDK: Ensure you have downloaded the SDK version recommended by the latest Expo release.
    • Android SDK Platform-Tools: Must be added to the system environment variables (PATH).
    • Virtual Device (AVD): Create an emulator with Google Play Services for local testing.
  1. Xcode: Downloaded directly from the Mac App Store.
  2. Xcode Command Line Tools: Install by running in the terminal:
    Ventana de terminal
    xcode-select --install
  3. Cocoapods: iOS dependency manager (sudo gem install cocoapods).

To create a new modern React Native project with Expo using PNPM, run the official interactive command in your working directory:

Ventana de terminal
# Crear proyecto con la plantilla por defecto recomendada usando PNPM
pnpm dlx create-expo-app mi-app-ia --template tabs
mi-app-ia/
├── app/ # Directorio de rutas (Expo Router)
│ ├── (tabs)/ # Grupo de pestañas de navegación inferior
│ │ ├── _layout.tsx # Definición del enrutador de pestañas
│ │ ├── index.tsx # Pantalla de inicio
│ │ └── explorar.tsx # Pantalla de exploración
│ ├── _layout.tsx # Enrutador raíz (Modales, Autenticación, etc.)
│ └── +not-found.tsx # Pantalla 404 de respaldo
├── assets/ # Imágenes, fuentes y recursos multimedia
├── components/ # Componentes UI reutilizables
├── constants/ # Colores, configuraciones globales y APIs
├── package.json # Dependencias y scripts del ciclo de vida
└── app.json # Configuración nativa del manifiesto de Expo

Once the dependency installation with PNPM is complete, access the project folder and start the development server:

Ventana de terminal
cd mi-app-ia
pnpm expo start

When starting the Expo server, a QR code and interactive control options will be displayed:

  • a Open in Android: Launches the application in an active Android Studio emulator or a USB-connected device.
  • i Open in iOS: Launches the application in the Xcode iOS simulator (requires macOS).
  • w Open in Web: Initializes the web version of the application (useful for rapid prototyping).
  • r Reload Application: Forces a full UI refresh on all connected devices.

Ensure the correct state of your environment before starting development. Run the automated Expo diagnostic command via PNPM:

Ventana de terminal
pnpm dlx expo-doctor
  • ✓ Node.js LTS Installation: Compatible and optimal version.
  • ✓ Environment Variables: ANDROID_HOME and JAVA_HOME assigned correctly.
  • ✓ Android SDK: Minimum components installed and recognized by adb.
  • ✓ Expo CLI: SDK in sync with the React Native version declared in package.json.
  • ✕ Cocoapods (Windows Warning): Successfully ignored if you are not developing for iOS on this workstation.