RN project fails with "Property body[6] of BlockStatement..." (Babel related issue)
See original GitHub issueEDIT by @kelset: this is caused by a Babel release, read more at this comment. The offending commit has been reverted, as mentioned here - so the issue is solved now. If you are still experiencing it, follow the steps described here.
PLEASE don’t post comments like “same here”, they only create noise
When creating a new project via npx react-native init Foo --template react-native-template-typescript
, then running the default yarn ios
metro throws a compile error:
error: node_modules/react-native/Libraries/Image/ImageAnalyticsTagContext.js: Property body[6] of BlockStatement expected node to be of a type ["Statement"] but instead got "AssignmentExpression"
Tested using:
- Typescript 3.9.4 and 4.3.5
- React Native: 0.64.1
- macOS 11.4
- node v14.15.1
- yarn 1.22.10
Issue Analytics
- State:
- Created 2 years ago
- Reactions:5
- Comments:48 (4 by maintainers)
Top Results From Across the Web
react-native android won't run on device - Stack Overflow
The problem is due to a babel update that affected the RN project. copy @babel from some other project and paste in node_modules...
Read more >babel/types
params : Array<Identifier | Pattern | RestElement> (required); body : BlockStatement | Expression (required); async : boolean (default: false ); expression ...
Read more >Victor K Varghese (@VictorKVarghese) / Twitter
RN project fails with "Property body[6] of BlockStatement..." (Babel related issue) · Issue #31960... EDIT by @kelset: this is caused by a Babel...
Read more >Is anyone else having trouble getting a successful react native ...
I am having the exact same problem trying to get a barebones react native 0.64.2 project running in the iOS simulator. I keep...
Read more >Learning-JavaScript-Ethan-Brown.pdf - Depun Retrag
This book is not a comprehensive reference to JavaScript or its related libraries. The ... problem solving, learning, and certification training.
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
this is a known issue caused by a bug in a newly released version of babel. it will impact all new react-native and expo apps. you can resolve it with yarn resolutions in a new project:
see some discussion here:
@Revolt9k me and @nicolo-ribaudo have just done a pairing session to verify that
@babel/plugin-transform-react-display-name
version7.15.1
works correctly.So, to more completely provide a resolution if you are still experiencing the problem:
yarn start --reset-cache
. You can also do a more complete nuke viarm -rf $TMPDIR/metro-*
.Doing so will ensure that Metro will pick up the correct plugin and things should work again for you too 😃