Skip to content

pnpm support - Autolinking cache never invalidates on pnpm-lock.yaml (stale autolinking.json) #57582

Closed

Description

@ACHP

Description

When using react native in a monorepo managed by pnpm, we can be in a state where the autolinking.json is stale and no matter if we remove all node_modules / re-install etc ... the module stays null.
This happens when jumping between branche with different dependencies.

It seems to be caused by

.files("yarn.lock", "package-lock.json", "package.json", "react-native.config.js"),
that watch for yarn.lock or package-lock.json but not pnpm-lock.yaml

I think in 2026, it's reasonable to think that developers might uses pnpm or bun as well.

Steps to reproduce

scenario: we're migrating away from react-native-fs. There is a branch A without it, and a branch B where it is still installed.

  1. On the branch A (where react-native-fs was removed). run the android build.
    (Result: autolinking.json has no react-native-fs, and the fingerprint matches that branch's package.json.)

  2. Switch to branch B (with react-native-fs). DON'T RUN PNPM INSTALL YET.

  3. Trigger an android build.
    ( The cache notices package.json changed, so it updates the fingerprint to match branch B package.json, it re-scans node_modules where react-native-fs still isn't installed, so it writes a fresh autolinking.json without it.)

  4. Now you run pnpm install
    This finally installs react-native-fs into node_modules. But installing does not change package.json, its content is identical. So the fingerprint still matches

  5. Every build after that: the cache checks the fingerprint, sees no change, concludes "nothing to do," and reuses the stale autolinking.json that's missing react-native-fs. The app builds, but at runtime the native module is null — your original error.

React Native Version

0.86.0

Affected Platforms

Runtime - Android

Output of npx @react-native-community/cli info

System:
  OS: macOS 26.4
  CPU: (12) arm64 Apple M3 Pro
  Memory: 293.45 MB / 18.00 GB
  Shell:
    version: "5.9"
    path: /bin/zsh
Binaries:
  Node:
    version: 24.14.0
    path: /Users/alexischappron/.local/share/mise/installs/node/24.14.0/bin/node
  Yarn: Not Found
  npm:
    version: 11.9.0
    path: /Users/alexischappron/.local/share/mise/installs/node/24.14.0/bin/npm
  Watchman:
    version: 2026.03.16.00
    path: /opt/homebrew/bin/watchman
Managers:
  CocoaPods:
    version: 1.16.2
    path: /Users/alexischappron/.local/share/mise/installs/ruby/3.4.9/bin/pod
SDKs:
  iOS SDK:
    Platforms:
      - DriverKit 25.5
      - iOS 26.5
      - macOS 26.5
      - tvOS 26.5
      - visionOS 26.5
      - watchOS 26.5
  Android SDK:
    API Levels:
      - "23"
      - "25"
      - "28"
      - "29"
      - "31"
      - "33"
      - "34"
      - "35"
      - "36"
    Build Tools:
      - 33.0.1
      - 34.0.0
      - 35.0.0
      - 35.0.1
      - 36.0.0
    System Images:
      - android-35 | Google Play ARM 64 v8a
    Android NDK: Not Found
IDEs:
  Android Studio: 2026.1 AI-261.23567.138.2612.15445185
  Xcode:
    version: 26.6/17F113
    path: /usr/bin/xcodebuild
Languages:
  Java:
    version: 17.0.18
    path: /Users/alexischappron/.local/share/mise/installs/java/zulu-17.64.17.0/bin/javac
  Ruby:
    version: 3.4.9
    path: /Users/alexischappron/.local/share/mise/installs/ruby/3.4.9/bin/ruby
npmPackages:
  "@react-native-community/cli": Not Found
  react:
    installed: 19.2.0
    wanted: 19.2.0
  react-native: Not Found
  react-native-macos: Not Found
npmGlobalPackages:
  "*react-native*": Not Found
Android:
  hermesEnabled: Not found
  newArchEnabled: Not found
iOS:
  hermesEnabled: Not found
  newArchEnabled: Not found

Stacktrace or Logs

[TypeError: Cannot read property 'RNFSFileTypeRegular' of null]

MANDATORY Reproducer

https://github.com/ACHP/pnpmautolinkissue

Screenshots and Videos

Image
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions