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.72k stars 467 forks source link

Error "ReferenceError: window is not defined" with React Native Web version. #1150

Open lucaskraus opened 2 weeks ago

lucaskraus commented 2 weeks ago

What happened?

I'm trying to use the Web version of my project, but the bundle just stop to running immediately after complete the process with the following error in exit:

/home/lucas/code/Frontend/node_modules/@react-native-async-storage/async-storage/lib/commonjs/AsyncStorage.js:63
    return createPromise(() => window.localStorage.getItem(key), callback);
                         ^
ReferenceError: window is not defined

Version

2.0.0

What platforms are you seeing this issue on?

System Information

System:
  OS: Linux 5.15 Ubuntu 22.04.3 LTS 22.04.3 LTS (Jammy Jellyfish)
  CPU: (16) x64 11th Gen Intel(R) Core(TM) i7-11800H @ 2.30GHz
  Memory: 9.21 GB / 15.51 GB
  Shell:
    version: 5.1.16
    path: /bin/bash
Binaries:
  Node:
    version: 20.15.1
    path: ~/.nvm/versions/node/v20.15.1/bin/node
  Yarn: Not Found
  npm:
    version: 10.7.0
    path: ~/.nvm/versions/node/v20.15.1/bin/npm
  Watchman: Not Found
SDKs:
  Android SDK: Not Found
IDEs:
  Android Studio: Not Found
Languages:
  Java:
    version: javac 22
    path: /home/lucas/.sdkman/candidates/java/current/bin/javac
  Ruby: Not Found
npmPackages:
  "@react-native-community/cli": Not Found
  react:
    installed: 18.2.0
    wanted: 18.2.0
  react-native:
    installed: 0.73.6
    wanted: 0.73.6
npmGlobalPackages:
  "*react-native*": Not Found
Android:
  hermesEnabled: Not found
  newArchEnabled: Not found
iOS:
  hermesEnabled: Not found
  newArchEnabled: Not found

Steps to Reproduce

hoahv20 commented 1 week ago

same issue. I was downgrade to version 1.23.1 but it's still occur