Skip to content

run-android Command Fails in Nx React Native App #30439

Description

@dhanushiya-k

Current Behavior

The following error occurs:

error: unknown command 'run-android'
Warning: command "react-native run-android" exited with non-zero status code

### Expected Behavior

The app should launch successfully on an Android emulator or device. 

### GitHub Repo

_No response_

### Steps to Reproduce

1.
### Steps to Reproduce  
1. Create an Nx workspace with PNPM:  
   ```sh
   npx create-nx-workspace --pm pnpm
  1. Add a React Native app:
    nx add @nx/react-native  
    nx g @nx/react-native:app apps/mobile-frontend  
    • Chose Vite as the bundler.
  2. Run pod install on macOS.
  3. Fix potential esbuild issues:
    pnpm add esbuild -D -w
  4. I have added the project.json file in the mobile-frontend directory as follows:
    {
      "name": "mobile-frontend",
      "$schema": "../../node_modules/nx/schemas/project-schema.json",
      "sourceRoot": "apps/mobile-frontend/src",
      "projectType": "application",
      "tags": [],
      "// targets": "to see all targets run: nx show project mobile --web",
      "targets": {}
    }
  5. Check project existence:
    nx show project mobile-frontend
  6. Run the Android app:
    nx run mobile-frontend:run-android
    

Nx Report

Nx logs show:  

NX   Ran target run-android for project mobile-frontend (772ms)

   ×  1/1 failed
   √  0/1 succeeded [0 read from cache]

Failure Logs

Package Manager Version

No response

Operating System

  • macOS
  • Linux
  • Windows
  • Other (Please specify)

Additional Information

Additional Context

  • Is run-android the correct command for Nx-managed React Native apps?
  • Do I need additional configurations for Vite?

Metadata

Metadata

Assignees

Type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions