'React Native: "SyntaxError: Unexpected token u in JSON at position 0 " on Apple M1
I've been battling this issue for many days now. I've found no viable solution here or through general web searches. I am the first on my team to receive the new M1 Macbook Pro laptop. I've resolved the initial hardware compatibility issues, like when to use Rosetta, but this problem has me stumped. My team with Intel Macbooks do not have this problem. So I can only assume it's M1-related.
I'm hoping that the collective knowledge of SO will help me resolve this intractable problem so that I can begin doing actually dev work. If you have any follow up questions, I'd be happy to answer them.
Problem:
On both iOS and android versions on my app, the app both builds and launches successfully according to the console log: success Successfully launched the app on the simulator. However, during the initial code execution, the results are the same for both platforms: SyntaxError: Unexpected token u in JSON at position 0 and then the app crashes. All network requests have status: 200.
What else could I check to help me track down the root cause of this crash?
OS: macOS 12.0.1
CPU: (10) x64 Apple M1 Pro
Memory: 349.05 MB / 32.00 GB
Shell: 5.8 - /bin/zsh
Binaries:
Node: 16.13.1 - ~/.nvm/versions/node/v16.13.1/bin/node
Yarn: 1.22.17 - ~/.nvm/versions/node/v16.13.1/bin/yarn
npm: 6.14.16 - ~/Documents/sams-fresh-app-reactnative/node_modules/.bin/npm
Watchman: 2022.01.03.00 - /opt/homebrew/bin/watchman
Managers:
CocoaPods: 1.11.2 - /usr/local/bin/pod
SDKs:
iOS SDK:
Platforms: DriverKit 21.2, iOS 15.2, macOS 12.1, tvOS 15.2, watchOS 8.3
Android SDK:
Android NDK: 22.1.7171670
IDEs:
Android Studio: 2020.3 AI-203.7717.56.2031.7935034
Xcode: 13.2.1/13C100 - /usr/bin/xcodebuild
Languages:
Java: 11.0.13 - /usr/bin/javac
npmPackages:
@react-native-community/cli: Not Found
react: 16.13.1 => 16.13.1
react-native: 0.64.1 => 0.64.1
react-native-macos: Not Found
npmGlobalPackages:
*react-native*: Not Found
Relevant console output
ExceptionsManager.js:180 SyntaxError: Unexpected token u in JSON at position 0
...
ExceptionsManager.js:180 Invariant Violation: Module AppRegistry is not a registered callable module (calling runApplication). A frequent cause of the error is that the application entry file path is incorrect.
This can also happen when the JS bundle is corrupt or there is an early initialization error when loading React Native.
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|
