I am having some trouble with upgrading my react-navigation from v3 to v5. I keep running into this error, at first I thought it was a bug but I am not finding any other plaints online about it. To be 100% sure the old versions weren't causing any issues, I pletely uninstalled all react-navigation and started from scratch with v5. I am still getting an error with the index file. It doesn't appear to understand the typescript...is this a known bug? Is there another step I need to take that is not in the documentation about installing Typescript?
UPDATE: ./types files is not piling correctly...it doesn't seem to recognize NavigationState or ActionHelpers...is this a bug? Has anyone seen this before?
UPDATE 2 i am running on RN V0.59 so I am thinking there could be a dependency issue. I am upgrading to V0.62.2 and seeing if the issue persists
SyntaxError: /Users/myusername/myprojectname/node_modules/@react-navigation/stack/src/index.tsx: Unexpected token (51:12)
49 | * Types 50 | */
51 | export type { | ^ 52 | StackNavigationOptions, 53 | StackNavigationProp, 54 | StackHeaderProps,
I am having some trouble with upgrading my react-navigation from v3 to v5. I keep running into this error, at first I thought it was a bug but I am not finding any other plaints online about it. To be 100% sure the old versions weren't causing any issues, I pletely uninstalled all react-navigation and started from scratch with v5. I am still getting an error with the index file. It doesn't appear to understand the typescript...is this a known bug? Is there another step I need to take that is not in the documentation about installing Typescript?
UPDATE: ./types files is not piling correctly...it doesn't seem to recognize NavigationState or ActionHelpers...is this a bug? Has anyone seen this before?
UPDATE 2 i am running on RN V0.59 so I am thinking there could be a dependency issue. I am upgrading to V0.62.2 and seeing if the issue persists
https://reactnavigation/docs/getting-started
Share Improve this question edited Apr 14, 2020 at 13:23 Olivia asked Apr 14, 2020 at 2:30 OliviaOlivia 2,1714 gold badges33 silver badges55 bronze badgesSyntaxError: /Users/myusername/myprojectname/node_modules/@react-navigation/stack/src/index.tsx: Unexpected token (51:12)
49 | * Types 50 | */
51 | export type { | ^ 52 | StackNavigationOptions, 53 | StackNavigationProp, 54 | StackHeaderProps,
3 Answers
Reset to default 7If you use TypeScript, do this:
- Delete
node_modules
and the lock file (yarn.lock
orpackage.lock
) - Upgrade TypeScript to latest i.e. 3.8.3.
- Run
yarn cache clean
ornpm cache clean
. - Run
yarn
ornpm install
. - Run
yarn react-native start --reset-cache
. - Run
yarn react-native run-android
.
If you don't, then follow these steps:
- Run
yarn add --dev @babel/core@^7.9.0 @babel/runtime@^7.9.0
. - Uninstall apk from
emulator/phone
. - Run
yarn react-native start --reset-cache
. - Run
yarn react-native run-android
.
If that did not work, go to android/
, and run gradlew clean
or ./gradlew clean
, remove the apk from you phone and rerun yarn react-native run-android
.
Hope this will helps you!
Delete your yarn.lock or package-json.lock file and run yarn/npm install.
Then try clearing cache with npx react-native start --reset-cache or expo start -c
References
Upgrade
Cache clear
For anyone who can't get it to work by removing node_modules
and whatnot:
Add @babel/core
as a global dependency (yarn global add @babel/core
/ npm install -g @babel/core
), because globally-installed expo-cli
won't recognize project-based babel installations for some reason.