react-native-async-storage / async-storage

An asynchronous, persistent, key-value storage system for React Native.
https://react-native-async-storage.github.io/async-storage/
MIT License
4.61k stars 458 forks source link

File '.project' generated by Eclipse Buildship breaks linking in monorepo #1072

Closed bananer closed 3 months ago

bananer commented 3 months ago

What happened?

In our monorepo setup (npm workspaces) all dependencies are hoisted into repo/node_modules. We have async-storage declared as dependencies in repo/lib/package.json and repo/app/package.json.

When running npm istall, async-storage is placed as expected in repo/node_modules/@react-native-async-storage/async-storage.

When building and running the Android version of repo/app, the file repo/app/node_modules/@react-native-async-storage/async-storage/android/.project and its parent directories are created. Its content looks like this:

<?xml version="1.0" encoding="UTF-8"?>
<projectDescription>
    <name>react-native-async-storage_async-storage</name>
    <comment>Project react-native-async-storage_async-storage created by Buildship.</comment>
...

Because of this directory existing, the next time the app is built, React Native does not include the async-storage native module from the hoisted node_modules and the app fails to start with errorr TypeError: Cannot read property 'asyncStore' of undefined and Error: [@RNC/AsyncStorage]: NativeModule: AsyncStorage is null.

Version

1.22.3

What platforms are you seeing this issue on?

System Information

info Fetching system and libraries information...
System:
  OS: Linux 6.5 Debian GNU/Linux 12 (bookworm) 12 (bookworm)
  CPU: (20) x64 13th Gen Intel(R) Core(TM) i9-13900H
  Memory: 42.13 GB / 93.96 GB
  Shell:
    version: 5.2.15
    path: /bin/bash
Binaries:
  Node:
    version: 18.19.0
    path: /usr/bin/node
  Yarn: Not Found
  npm:
    version: 10.4.0
    path: /usr/local/bin/npm
  Watchman: Not Found
SDKs:
  Android SDK:
    API Levels:
      - "32"
      - "33"
      - "34"
    Build Tools:
      - 30.0.3
      - 33.0.0
      - 33.0.1
      - 34.0.0
    System Images:
      - android-31 | Google Play Intel x86_64 Atom
      - android-34 | Google APIs Intel x86_64 Atom
    Android NDK: Not Found
IDEs:
  Android Studio: Not Found
Languages:
  Java:
    version: 17.0.10
    path: /usr/bin/javac
  Ruby: Not Found
npmPackages:
  "@react-native-community/cli": Not Found
  react: Not Found
  react-native: Not Found
npmGlobalPackages:
  "*react-native*": Not Found
Android:
  hermesEnabled: Not found
  newArchEnabled: Not found
iOS:
  hermesEnabled: Not found
  newArchEnabled: Not found

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

Steps to Reproduce

bananer commented 3 months ago

Workaround of course is to delete repo/app/node_modules/@react-native-async-storage/ every time before building the Android app.

bananer commented 3 months ago

Another workaround is to downgrade to 1.19.8

bananer commented 3 months ago

After spending quite some time trying to get to the bottom of this, it seems like what actually caused this file to appear was VSCode with the Java plugin running with repo/node_modules/@react-native-async-storage/async-storage directory open. :facepalm: