react-native-template-typescript: Property body[6] of BlockStatement expected node to be of a type ["Statement"] but instead got "AssignmentExpression"

Expected results

Run react native template

Observed results

Cannot run blank application created just after created it (npx react-native init MyApp --template react-native-template-typescript).

Logs

> react-native start

                                                      
                        #######                       
                   ################                   
                #########     #########               
            #########             ##########          
        #########        ######        #########      
       ##########################################     
      #####      #####################       #####    
      #####          ##############          #####    
      #####    ###       ######       ###    #####    
      #####    #######            #######    #####    
      #####    ###########    ###########    #####    
      #####    ##########################    #####    
      #####    ##########################    #####    
      #####      ######################     ######    
       ######        #############        #######     
         #########        ####       #########        
              #########          #########            
                  ######### #########                 
                       #########                      
                                                      
                                                      
                    Welcome to Metro!
              Fast - Scalable - Integrated



To reload the app press "r"
To open developer menu press "d"

 BUNDLE  ./index.js 

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"
 BUNDLE  ./index.js 

error: node_modules/react-native/Libraries/Components/ScrollView/ScrollViewContext.js: Property body[6] of BlockStatement expected node to be of a type ["Statement"] but instead got "AssignmentExpression"
 BUNDLE  ./index.js 

error: node_modules/react-native/Libraries/Components/ScrollView/ScrollViewContext.js: Property body[6] of BlockStatement expected node to be of a type ["Statement"] but instead got "AssignmentExpression"
 BUNDLE  ./index.js 

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"
info Opening developer menu...
 BUNDLE  ./index.js 

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"

Steps to reproduce

  1. Initialise repository
  2. Try to runnit

OS: macOS 11.4 Hardware MacBook Pro 15-inch, 2019 (2.3 GHz 8-Core Intel Core i9, 32 GB 2400 MHz DDR4, Radeon Pro Vega 20) Xcode: Version 12.5.1 (12E507) NodeJS: v14.17.0

About this issue

  • Original URL
  • State: closed
  • Created 3 years ago
  • Reactions: 18
  • Comments: 18 (1 by maintainers)

Commits related to this issue

Most upvoted comments

I found a solution.

Download @babel from here: https://drive.google.com/file/d/1-z_4H_z4x075unZqZD41WYUwY_hsrKox/view

And replace the @babel folder in node_modules

Same issue on MacBook Pro (15-inch, 2018) Processor Name: 6-Core Intel Core i7 Processor Speed: 2.2 GHz Running on macOS Big Sur

XCode - Version 12.5.1 (12E507) Node - v14.15.0

Tried to do basic installation stated at https://reactnative.dev/docs/environment-setup

Steps to Reproduce

Step 1: npm install -g expo-cli

Step 2: expo init AwesomeProject

Step 4: cd into the folder

Step 5: expo start

Step 6: Select iOS Simulator on the Browser

In the terminal, getting the following error -

Logs for your project will appear below. Press Ctrl+C to exit. 

Failed building JavaScript bundle.
node_modules/react-native/Libraries/Components/ScrollView/ScrollView.js: Property body[42] of BlockStatement expected node to be of a type ["Statement"] but instead got "AssignmentExpression"

This is the screenshot in the Expo Go App on the Simulator

Screenshot 2021-08-05 at 8 30 20 AM

@gabacode I did not understand the solution as I am new to react native

You need to add babel “resolutions” to your package.json file

Example:

{
  "main": "index.js",
  "dependencies": {
    "expo": "~42.0.1",
    "react-native": "~0.63.4",
  },
  "resolutions": {
    "@babel/plugin-transform-react-display-name": "7.14.5"
  },
  "private": true
}

I found a solution.

Download @babel from here: https://drive.google.com/file/d/C3NZ0R3D/view

And replace the @babel folder in node_modules

Guys! I would recommend to not download any modules outside npm! This bug should be fixed already according to other issues. I’ll check more later today. Probably it was babel issue.

Try this solution , works for me!

hi guys, same problem I had this problem while building App. I can’t figure out how to fix it, can someone here help me?

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”

I def solved this by doing the following steps:

  1. remove all ^ from babel packages
  2. add this to package.json
  "resolutions": {
    "@babel/plugin-transform-react-display-name": "7.14.5"
  },
  1. rm -rf node_modules
  2. rm -f package-lock.json file
  3. npm install and start it up
  4. hold breath as it builds

thanks @gabacode for the help on this!