react-native
react-native copied to clipboard
error: SyntaxError: .../node_modules/react-native/Libraries/Components/Touchable/Touchable.js: Unexpected token, expected "]" (25:45)
New Version
0.70.0
Old Version
0.63.3
Build Target(s)
iOS 16.0
Output of react-native info
System: OS: macOS 13.0 CPU: (8) x64 Apple M1 Memory: 27.19 MB / 16.00 GB Shell: 5.8.1 - /bin/zsh Binaries: Node: 16.14.0 - ~/.nvm/versions/node/v16.14.0/bin/node Yarn: 1.22.19 - ~/.yarn/bin/yarn npm: 8.3.1 - ~/.nvm/versions/node/v16.14.0/bin/npm Watchman: 2021.06.07.00 - /opt/homebrew/bin/watchman Managers: CocoaPods: 1.11.3 - /Users/alex/.rbenv/shims/pod SDKs: iOS SDK: Platforms: DriverKit 21.4, iOS 16.0, macOS 12.3, tvOS 16.0, watchOS 9.0 Android SDK: API Levels: 28, 29, 30, 31 Build Tools: 28.0.3, 29.0.2, 30.0.2, 30.0.3, 31.0.0, 31.0.0 System Images: android-25 | Google APIs ARM 64 v8a, android-29 | Google Play ARM 64 v8a, android-30 | Google APIs Intel x86 Atom, android-30 | Google Play ARM 64 v8a, android-31 | Google APIs ARM 64 v8a Android NDK: Not Found IDEs: Android Studio: 4.2 AI-202.7660.26.42.7486908 Xcode: 14.0/14A309 - /usr/bin/xcodebuild Languages: Java: 11.0.10 - /opt/homebrew/opt/openjdk@11/bin/javac npmPackages: @react-native-community/cli: Not Found react: 18.1.0 => 18.1.0 react-native: 0.70.1 => 0.70.1 react-native-macos: Not Found npmGlobalPackages: react-native: Not Found
Issue and Reproduction Steps
- Build the app using Xcode 14
- yarn start --reset-cache
- Error displays
+1 Same issue is happening to me
Same for Android upgrading form 0.63.4
By the way @here. I had to patch that file using the version from 0.69 with patch-package to get the latest version of react-native to compile after upgrading from 0.63.3
Just upgraded from 0.63.4 to 0.70.1 and got this error
This helped me
rm -fr node_modules
watchman watch-del-all
Running into this error as well, upgraded from 0.64.0 to 0.70.2
Running into this error as well, upgraded from 0.67.3 to 0.70.3
Hello, solve this issue writing this in app console : rm -rf node_modules rm yarn.lock yarn
Issue persists when upgrading from 0.69.3 to 0.70.4
Temporary work around react-native+0.70.4.patch
diff --git a/node_modules/react-native/Libraries/Components/Touchable/Touchable.js b/node_modules/react-native/Libraries/Components/Touchable/Touchable.js
index ea448b3..a1fb596 100644
--- a/node_modules/react-native/Libraries/Components/Touchable/Touchable.js
+++ b/node_modules/react-native/Libraries/Components/Touchable/Touchable.js
@@ -21,18 +21,7 @@ import type {ColorValue} from '../../StyleSheet/StyleSheet';
import type {EdgeInsetsProp} from '../../StyleSheet/EdgeInsetsPropType';
import type {PressEvent} from '../../Types/CoreEventTypes';
-const extractSingleTouch = (nativeEvent: {
- +changedTouches: $ReadOnlyArray<PressEvent['nativeEvent']>,
- +force?: number,
- +identifier: number,
- +locationX: number,
- +locationY: number,
- +pageX: number,
- +pageY: number,
- +target: ?number,
- +timestamp: number,
- +touches: $ReadOnlyArray<PressEvent['nativeEvent']>,
-}) => {
+const extractSingleTouch = nativeEvent => {
const touches = nativeEvent.touches;
const changedTouches = nativeEvent.changedTouches;
const hasTouches = touches && touches.length > 0;
I also had a similar problem
It's because babel core and runtime are out of date when you upgrade.
Even though the package.json specifies an earlier version when you start a new project from scratch it installs a newer version that works. I am sure all testing was done from scratch.
Force an update to:
"@babel/core": 7.20.5 "@babel/runtime": 7.20.6
The versions I supplied came right from the lock files of a new install and resolve the issue.
This should be fixed in main by https://github.com/facebook/react-native/commit/3e19c9764634049731b4bf96dc1c716064394d62. @cortinico, might be worth picking the Babel updates into 71?
Edit: Thinking about it, the RN template dependencies shouldn’t be the immediate cause here - the syntax error is coming through Metro (whose Babel deps were bumped simultaneously), ~~so we should be ok as long as the Metro 0.73.5 release makes it into RN 0.71.~~
Edit 2: Scratch that, https://github.com/facebook/metro/commit/5f9ba404ca5510386c509cb649295810cfd87f5f didn’t make it into the last Metro release.
Edit 3: This is now fixed in Metro 0.73.6, which will be part of the next CLI release and should make it into RN 0.71.0. CC @kelset, @dmytrorykun.
Can anyone help me solve this issue? I Mean What to do?
@irfanukani Run yarn add @babel/core --dev
@dcangulo I already did that.

Can anyone help me solve this issue?
Update these two dev dependencies to the below versions "@babel/core": 7.20.5 "@babel/runtime": 7.20.6
Then delete your node modules and yarn install or npm install
It should start working.
Changing package.json might not get what you want and shouldn't be necessary. The simplest thing to do, if you can, is to delete yarn.lock and node_modules and run yarn again.
@robhogan it is a bad idea. this should be done only if package.json has fixed versions without ^
Updating versions within your project's package.json will force an update to your top-level Babel but won't necessarily change the lockfile entry that locks Metro to a buggy version of Babel, so you may still get those buggy older versions nested within your node_modules - that's why that fix hasn't worked for some people in this thread.
By deleting yarn.lock, you'll allow Yarn to look up the latest versions of Babel that match Metro's dependencies (as well as your project's), which today will be 7.20.x.
The only other way to be sure of the version of a transitive dependency would be to use Yarn's package.json#resolutions, but that's more complex than necessary here (it may be useful for folks who don't want to delete the whole lockfile or manually edit it).
Seeing this issue after upgrading to 0.70 but only when running jest tests. Running the app in simulator or on device works fine.
@babel/core: 7.20.12
@babel/runtime: 7.20.7
SyntaxError: node_modules/react-native/Libraries/Components/Touchable/Touchable.js: Unexpected token, expected "]" (25:45)
23 |
24 | const extractSingleTouch = (nativeEvent: {
> 25 | +changedTouches: $ReadOnlyArray<PressEvent['nativeEvent']>,
| ^
26 | +force?: number,
27 | +identifier: number,
28 | +locationX: number,
at Object._raise (node_modules/jest-config/node_modules/@babel/parser/src/parser/error.js:60:45)
If I try to use the exact versions of babel runtime and core suggested earlier by @aprakimble, I get a different issue (Cannot find module '@babel/parser' to link)
It sounds like this is probably solved in RN 0.71, but I'm on 0.70.7 and still getting issues. Adding this to my package.json solved it for me. See https://docs.npmjs.com/cli/v8/configuring-npm/package-json#overrides for details of what this does.
"overrides": {
"@react-native-community/cli": "^10.1.0"
}
Upgrading from 69 up to 70 and seeing the same error, however I am not seeing it in runtime but instead when running tests.
I've gone ahead and updated both babel packages to the following:
@babel/core: 7.20.12 @babel/runtime: 7.20.7
But still seeing the issue present in tests.
@bwindsor I am going to try your solution to see if it will work in our current branch with the upgrade. Does your suggestion include clearing out the yarn.lock file to make sure the desired cli is picked up?
@Coffeegerm I don't remember if I also removed the .lock file, or if just running npm install / yarn install again was sufficient. Sorry to not be of more help on that!
@bwindsor Dang, neither
"overrides": {
"@react-native-community/cli": "^10.1.0"
}
or
"overrides": {
"react-native: {
"@react-native-community/cli": "^10.1.0"
}
}
have seemed to work. Not seeing any indication of the yarn.lock file getting updated for the new dependency version 😞
Has anyone else found a possible solution beyond a patch-package?
ANYONE EVER SOLVE THIS ISSUE?
working on a project that I took from RN 0.63.3 to 0.70.0 and I am now seeing this issue, I tried removing node modules and re-installing.
This issue is stale because it has been open 180 days with no activity. Remove stale label or comment or this will be closed in 7 days.
This issue was closed because it has been stalled for 7 days with no activity.