Skip to content

Could not patch module system on blank Expo RN project #39

@samchencode

Description

@samchencode

Describe the bug

What I'm doing

Following the quick start guide with a new Expo React Native app, blank template. I'm running iOS 26.1 on Simulator.

I built and ran the app as ios bundle with npx expo run:ios and then ran npx react-native-harness --harnessRunner ios. This results in an error port 8081 is not available. So I turn off the expo dev server which occupies 8081. Then I get Could not patch module system

What I expect

I copied the tests in the quick start into __tests__/example.harness.js

I expect the tests in example.harness.js to run and pass

What is happening

I get error Could not patch module system

Output

npx react-native-harness --harnessRunner ios
 HARNESS  Preparing to run tests using ios runner

Test Suites: 0 of 1 total
Tests:       0 total
Snapshots:   0 total
Time:        0.072 s
Ran all test suites.
 HARNESS  Metro port 8081 is not available
npx react-native-harness --harnessRunner ios
 HARNESS  Preparing to run tests using ios runner

Test Suites: 0 of 1 total
Tests:       0 total
Snapshots:   0 total
Time:        0.299 s
Ran all test suites.
CouldNotPatchModuleSystemError: Could not patch module system
    at getMetroConfigPath (/Volumes/jaunty/programming/tinker/fiddle-expo-blank/node_modules/@react-native-harness/metro/dist/moduleSystem.js:22:11)
    at getMetroDefaultsPath (/Volumes/jaunty/programming/tinker/fiddle-expo-blank/node_modules/@react-native-harness/metro/dist/moduleSystem.js:25:29)
    at patchModuleSystem (/Volumes/jaunty/programming/tinker/fiddle-expo-blank/node_modules/@react-native-harness/metro/dist/moduleSystem.js:37:29)
    at /Volumes/jaunty/programming/tinker/fiddle-expo-blank/node_modules/@react-native-harness/metro/dist/withRnHarness.js:21:46
    at process.processTicksAndRejections (node:internal/process/task_queues:105:5)
    at async getMetroInstance (file:///Volumes/jaunty/programming/tinker/fiddle-expo-blank/node_modules/@react-native-harness/bundler-metro/dist/factory.js:38:20)
    at async Promise.all (index 0)
    at async getHarnessInternal (file:///Volumes/jaunty/programming/tinker/fiddle-expo-blank/node_modules/@react-native-harness/jest/dist/harness.js:7:61)
    at async getHarness (file:///Volumes/jaunty/programming/tinker/fiddle-expo-blank/node_modules/@react-native-harness/jest/dist/harness.js:63:25)
    at async setup (file:///Volumes/jaunty/programming/tinker/fiddle-expo-blank/node_modules/@react-native-harness/jest/dist/setup.js:47:21)

System Info

npx react-native info                       
info Fetching system and libraries information...
System:
  OS: macOS 26.2
  CPU: (8) arm64 Apple M1
  Memory: 97.95 MB / 8.00 GB
  Shell:
    version: "5.9"
    path: /bin/zsh
Binaries:
  Node:
    version: 22.12.0
    path: /Users/bapspaf/.nvm/versions/node/v22.12.0/bin/node
  Yarn:
    version: 1.22.22
    path: /Users/bapspaf/.nvm/versions/node/v22.12.0/bin/yarn
  npm:
    version: 10.9.0
    path: /Users/bapspaf/.nvm/versions/node/v22.12.0/bin/npm
  Watchman: Not Found
Managers:
  CocoaPods:
    version: 1.16.2
    path: /opt/homebrew/bin/pod
SDKs:
  iOS SDK:
    Platforms:
      - DriverKit 25.1
      - iOS 26.1
      - macOS 26.1
      - tvOS 26.1
      - visionOS 26.1
      - watchOS 26.1
  Android SDK: Not Found
IDEs:
  Android Studio: 2025.2 AI-252.27397.103.2522.14514259
  Xcode:
    version: 26.1/17B55
    path: /usr/bin/xcodebuild
Languages:
  Java: Not Found
  Ruby:
    version: 2.6.10
    path: /usr/bin/ruby
npmPackages:
  "@react-native-community/cli":
    installed: 20.0.2
    wanted: ^20.0.2
  react:
    installed: 19.1.0
    wanted: 19.1.0
  react-native:
    installed: 0.81.5
    wanted: 0.81.5
  react-native-macos: Not Found
npmGlobalPackages:
  "*react-native*": Not Found
Android:
  hermesEnabled: Not found
  newArchEnabled: Not found
iOS:
  hermesEnabled: true
  newArchEnabled: true

info React Native v0.83.0 is now available (your project is running on v0.81.5).
info Changelog: https://github.com/facebook/react-native/releases/tag/v0.83.0
info Diff: https://react-native-community.github.io/upgrade-helper/?from=0.81.5&to=0.83.0
info For more info, check out "https://reactnative.dev/docs/upgrading?os=macos".

React Native Harness Version

1.0.0-alpha.19

Reproduction

https://github.com/samchencode/bug-report-expo-harness

Steps to reproduce

  1. Create iOS Simulator Device (iPhone 14 Pro) named i6.7 with iOS 26.1
  2. npm install
  3. npx expo run:ios
  4. npx react-native-harness --harnessRunner ios

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions