react-native
react-native copied to clipboard
Unexpected keyword 'typeof'
Description
Hi, I got this weird issue after running npx react-native run-android in my new project.
Build success but got this error while running the app:
{PROJECT_DIR/node_modules/react-native/index.js: Unexpected keyword 'typeof'
in file node_modules/react-native/index.js:
import typeof AccessibilityInfo from './Libraries/Components/AccessibilityInfo/AccessibilityInfo'; import typeof ActivityIndicator from './Libraries/Components/ActivityIndicator/ActivityIndicator'; import typeof Button from './Libraries/Components/Button'; import typeof DrawerLayoutAndroid from './Libraries/Components/DrawerAndroid/DrawerLayoutAndroid';
Steps to reproduce
- Create new project with 0.74.1 version.
- run npx react-native run-android
- Got the error
React Native Version
0.74.1
Affected Platforms
Runtime - Android
Output of npx react-native info
System:
OS: macOS 14.4.1
CPU: (12) x64 Intel(R) Core(TM) i7-8700B CPU @ 3.20GHz
Memory: 8.23 GB / 32.00 GB
Shell:
version: "5.9"
path: /bin/zsh
Binaries:
Node:
version: 20.11.1
path: /usr/local/bin/node
Yarn:
version: 3.6.4
path: /usr/local/bin/yarn
npm:
version: 10.7.0
path: /usr/local/bin/npm
Watchman:
version: 2024.05.06.00
path: /usr/local/bin/watchman
Managers:
CocoaPods:
version: 1.15.2
path: /usr/local/bin/pod
SDKs:
iOS SDK:
Platforms:
- DriverKit 23.0
- iOS 17.0
- macOS 14.0
- tvOS 17.0
- watchOS 10.0
Android SDK: Not Found
IDEs:
Android Studio: 2023.3 AI-233.14808.21.2331.11709847
Xcode:
version: 15.0.1/15A507
path: /usr/bin/xcodebuild
Languages:
Java:
version: 15.0.1
path: /usr/bin/javac
Ruby:
version: 2.6.10
path: /usr/bin/ruby
npmPackages:
"@react-native-community/cli": Not Found
react:
installed: 18.2.0
wanted: 18.2.0
react-native:
installed: 0.73.8
wanted: ^0.73.8
react-native-macos: Not Found
npmGlobalPackages:
"*react-native*": Not Found
Android:
hermesEnabled: true
newArchEnabled: false
iOS:
hermesEnabled: true
newArchEnabled: false
Stacktrace or Logs
Unexpected keyword 'typeof'. (14:7)
12 |
13 | // Components
> 14 | import typeof AccessibilityInfo from './Libraries/Components/AccessibilityInfo/AccessibilityInfo';
| ^
15 | import typeof ActivityIndicator from './Libraries/Components/ActivityIndicator/ActivityIndicator';
16 | import typeof Button from './Libraries/Components/Button';
17 | import typeof DrawerLayoutAndroid from './Libraries/Components/DrawerAndroid/DrawerLayoutAndroid';
Reproducer
https://github.com/nazrincode
Screenshots and Videos
No response
| :warning: | Missing Reproducible Example |
|---|---|
| :information_source: | We could not detect a reproducible example in your issue report. Please provide either:
|
I've just tested this locally, and cannot reproducer.
You definitely have something going on with your project as from your react-native info we see:
npmPackages:
"@react-native-community/cli": Not Found
react:
installed: 18.2.0
wanted: 18.2.0
react-native:
installed: 0.73.8
wanted: ^0.73.8
While in the RN version you mention 0.74.1 which seems odd.
Exact same thing is happening to me but not immediately. It first happened when trying to set up Drizzle with Expo sqlite, every time I tried to run drizzle's generate command to generate migrations I would get this kind of error. It's now happening when trying to run npx convex dev.