javascript - Cannot read property 'bindings' of null Error in Reactnative - Stack Overflow

I am getting following error message on emulatordevice while running the app from react-native.** ERRO

I am getting following error message on emulator/device while running the app from react-native.

** ERROR **

  The development server returned response error code: 500

URL: http: //10.0.2.2:8081/index.delta?platform=android&dev=true&minify=false

  Body: {
    "type": "TransformError",
    "lineNumber": 0,
    "errors": [{
      "description": "/Users/admin/Documents/PULSE/Phase II/Projects/pulse-mobile-mon-rn/App.js: Cannot read property 'bindings' of null",
      "lineNumber": 0
    }],
    "name": "SyntaxError",
    "message": "/Users/admin/Documents/PULSE/Phase II/Projects/pulse-mobile-mon-rn/App.js: Cannot read property 'bindings' of null",
    "stack": "TypeError: Cannot read property 'bindings' of null\n    at Scope.moveBindingTo (/Users/admin/Documents/PULSE/Phase II/Projects/pulse-mobile-mon-rn/node_modules/@babel/traverse/lib/scope/index.js:867:13)\n    at BlockScoping.updateScopeInfo (/Users/admin/Documents/PULSE/Phase II/Projects/pulse-mobile-mon-rn/node_modules/babel-plugin-transform-es2015-block-scoping/lib/index.js:364:17)\n    at BlockScoping.run (/Users/admin/Documents/PULSE/Phase II/Projects/pulse-mobile-mon-rn/node_modules/babel-plugin-transform-es2015-block-scoping/lib/index.js:330:12)\n    at PluginPass.BlockStatementSwitchStatementProgram (/Users/admin/Documents/PULSE/Phase II/Projects/pulse-mobile-mon-rn/node_modules/babel-plugin-transform-es2015-block-scoping/lib/index.js:70:24)\n    at newFn (/Users/admin/Documents/PULSE/Phase II/Projects/pulse-mobile-mon-rn/node_modules/@babel/traverse/lib/visitors.js:193:21)\n    at NodePath._call (/Users/admin/Documents/PULSE/Phase II/Projects/pulse-mobile-mon-rn/node_modules/@babel/traverse/lib/path/context.js:53:20)\n    at NodePath.call (/Users/admin/Documents/PULSE/Phase II/Projects/pulse-mobile-mon-rn/node_modules/@babel/traverse/lib/path/context.js:40:17)\n    at NodePath.visit (/Users/admin/Documents/PULSE/Phase II/Projects/pulse-mobile-mon-rn/node_modules/@babel/traverse/lib/path/context.js:88:12)\n    at TraversalContext.visitQueue (/Users/admin/Documents/PULSE/Phase II/Projects/pulse-mobile-mon-rn/node_modules/@babel/traverse/lib/context.js:118:16)"
  }
processBundleResult
BundleDownloader.java: 296
access$200
BundleDownloader.java: 37
onResponse
BundleDownloader.java: 174
execute
RealCall.java: 153
run
NamedRunnable.java: 32
runWorker
ThreadPoolExecutor.java: 1162
run
ThreadPoolExecutor.java: 636
run
Thread.java: 764

I am getting following error message on emulator/device while running the app from react-native.

** ERROR **

  The development server returned response error code: 500

URL: http: //10.0.2.2:8081/index.delta?platform=android&dev=true&minify=false

  Body: {
    "type": "TransformError",
    "lineNumber": 0,
    "errors": [{
      "description": "/Users/admin/Documents/PULSE/Phase II/Projects/pulse-mobile-mon-rn/App.js: Cannot read property 'bindings' of null",
      "lineNumber": 0
    }],
    "name": "SyntaxError",
    "message": "/Users/admin/Documents/PULSE/Phase II/Projects/pulse-mobile-mon-rn/App.js: Cannot read property 'bindings' of null",
    "stack": "TypeError: Cannot read property 'bindings' of null\n    at Scope.moveBindingTo (/Users/admin/Documents/PULSE/Phase II/Projects/pulse-mobile-mon-rn/node_modules/@babel/traverse/lib/scope/index.js:867:13)\n    at BlockScoping.updateScopeInfo (/Users/admin/Documents/PULSE/Phase II/Projects/pulse-mobile-mon-rn/node_modules/babel-plugin-transform-es2015-block-scoping/lib/index.js:364:17)\n    at BlockScoping.run (/Users/admin/Documents/PULSE/Phase II/Projects/pulse-mobile-mon-rn/node_modules/babel-plugin-transform-es2015-block-scoping/lib/index.js:330:12)\n    at PluginPass.BlockStatementSwitchStatementProgram (/Users/admin/Documents/PULSE/Phase II/Projects/pulse-mobile-mon-rn/node_modules/babel-plugin-transform-es2015-block-scoping/lib/index.js:70:24)\n    at newFn (/Users/admin/Documents/PULSE/Phase II/Projects/pulse-mobile-mon-rn/node_modules/@babel/traverse/lib/visitors.js:193:21)\n    at NodePath._call (/Users/admin/Documents/PULSE/Phase II/Projects/pulse-mobile-mon-rn/node_modules/@babel/traverse/lib/path/context.js:53:20)\n    at NodePath.call (/Users/admin/Documents/PULSE/Phase II/Projects/pulse-mobile-mon-rn/node_modules/@babel/traverse/lib/path/context.js:40:17)\n    at NodePath.visit (/Users/admin/Documents/PULSE/Phase II/Projects/pulse-mobile-mon-rn/node_modules/@babel/traverse/lib/path/context.js:88:12)\n    at TraversalContext.visitQueue (/Users/admin/Documents/PULSE/Phase II/Projects/pulse-mobile-mon-rn/node_modules/@babel/traverse/lib/context.js:118:16)"
  }
processBundleResult
BundleDownloader.java: 296
access$200
BundleDownloader.java: 37
onResponse
BundleDownloader.java: 174
execute
RealCall.java: 153
run
NamedRunnable.java: 32
runWorker
ThreadPoolExecutor.java: 1162
run
ThreadPoolExecutor.java: 636
run
Thread.java: 764

Package.json



{
  "name": "pulsemobile",
  "version": "0.0.1",
  "private": true,
  "scripts": {
    "start": "node node_modules/react-native/local-cli/cli.js start",
    "test": "jest",
    "pretty": "prettier --semi true --print-width 120 --arrow-parens always --single-quote --trailing-ma all --write \"src/**/*.js\"",
    "premit": "lint-staged",
    "offline-android": "react-native bundle --dev false --platform android --entry-file index.js --bundle-output ./android/app/build/intermediates/assets/debug/index.android.bundle --assets-dest ./android/app/build/intermediates/res/merged/debug",
    "offline-ios": "react-native bundle --entry-file='index.js' --bundle-output='./ios/playmaker/main.jsbundle' --dev=false --platform='ios' --assets-dest='./ios'"
  },
  "lint-staged": {
    "*.js": [
      "eslint --fix",
      "yarn pretty",
      "git add"
    ]
  },
  "dependencies": {
    "@babel/runtime": "^7.0.0",
    "axios": "^0.18.0",
    "dateformat": "^3.0.3",
    "native-base": "^2.7.1",
    "prop-types": "^15.6.2",
    "react": "16.5.0",
    "react-native": "0.57.1",
    "react-native-device-settings": "^1.2.0",
    "react-native-extra-dimensions-android": "^0.21.0",
    "react-native-fused-location": "^0.2.1",
    "react-native-geocoding": "^0.2.0",
    "react-native-iphone-x-helper": "^1.1.0",
    "react-native-permissions": "^1.1.1",
    "react-native-vector-icons": "^5.0.0",
    "react-navigation": "^v1.3.2",
    "react-navigation-redux-helpers": "^1.0.2",
    "react-redux": "^5.0.6",
    "redux": "^3.7.2",
    "redux-logger": "^3.0.6",
    "redux-thunk": "^2.2.0"
  },
  "devDependencies": {
    "babel-eslint": "^8.2.5",
    "babel-jest": "23.6.0",
    "babel-preset-react-native": "4.0.0",
    "enzyme": "^3.6.0",
    "enzyme-adapter-react-16": "^1.4.0",
    "eslint-config-airbnb": "^17.0.0",
    "eslint-plugin-flowtype": "^2.49.3",
    "eslint-plugin-import": "^2.13.0",
    "eslint-plugin-jsx-a11y": "^6.0.3",
    "eslint-plugin-react": "^7.10.0",
    "husky": "^0.14.3",
    "eslint": "^5.0.1",
    "jest": "23.6.0",
    "metro-react-native-babel-preset": "0.46.0",
    "react-test-renderer": "16.5.0",
    "lint-staged": "^7.2.0",
    "prettier": "^1.13.6",
    "react-dom": "^16.4.2",
    "redux-mock-store": "^1.5.3"
  },
  "jest": {
    "collectCoverage": true,
    "preset": "react-native",
    "transformIgnorePatterns": [
      "node_modules/(realm)/"
    ],
    "setupTestFrameworkScriptFile": "./test/setupJest.js",
    "moduleDirectories": [
      "node_modules"
    ],
    "transform": {
      "^.+\\.jsx?$": "babel-jest"
    },
    "unmockedModulePathPatterns": [
      "promise",
      "source-map"
    ]
  },
  "rnpm": {
    "assets": [
      "./src/app/assets/fonts/"
    ]
  }
}

App.js This the content inside App.js file

 

   /**
     * Sample React Native App
     * https://github./facebook/react-native
     *
     * @format
     * @flow
     */

import React, { Component } from 'react';
import { Provider } from 'react-redux';
import store from './src/lib/Store';
import Root from './src/ponents/Root';

export default class App extends Component {
  render() {
    return (
      <Provider store={store}>
        <Root />
      </Provider>
    );
  }
}

Index.js file content



/** @format */

import {AppRegistry} from 'react-native';
import App from './App';
import {name as appName} from './app.json';

AppRegistry.registerComponent(appName, () => App);

**.babelrc:: **

{ "presets": [ "react-native" ] }

I have tried with following links solution, but none of these solutions solved this issue

  1. Upgrade to babel 7: Cannot read property 'bindings' of null
  2. react-native cannot read property 'bindings' of null
  3. https://github./babel/babel/issues/8575
  4. https://github./storybooks/storybook/issues/3937
Share Improve this question edited Oct 8, 2018 at 20:11 Masthan Vali Syed asked Oct 8, 2018 at 20:00 Masthan Vali SyedMasthan Vali Syed 3976 silver badges23 bronze badges 5
  • Have you find any solution on this? We are also facing the same issue – Mrug Commented Oct 9, 2018 at 7:18
  • @Mrug I didn't get the solution for this issue yet. Please let me know if you a solution. – Masthan Vali Syed Commented Oct 9, 2018 at 9:25
  • I tried with a very fresh project, but facing the same issue – Mrug Commented Oct 9, 2018 at 9:40
  • me too. surprisingly, the same project works in another PC. I am wondering what would have gone wrong in my environment. – Masthan Vali Syed Commented Oct 9, 2018 at 11:24
  • @Mrug See below my answer this works for me. – Masthan Vali Syed Commented Oct 13, 2018 at 8:20
Add a ment  | 

2 Answers 2

Reset to default 3
  1. Inside ".babelrc" file:

{ "presets": [ "module:metro-react-native-babel-preset" ] }

  1. On terminal "npm install".
  2. On terminal "react-native run-android".

This works for me.

I have faced the same problem and did the following:

  1. initiate the project with react-native init --"version=0.57.0" projectName.
  2. On index.js change the AppRegistry.registerComponent(appName, () => App); to AppRegistry.registerComponent('the_name_you_have_given_on_your_project', () => App);
  3. Delete line import {name as appName} from './app.json';
  4. run with react-native run-ios or react-native run-android

发布者:admin,转转请注明出处:http://www.yc00.com/questions/1745469838a4629083.html

相关推荐

发表回复

评论列表(0条)

  • 暂无评论

联系我们

400-800-8888

在线咨询: QQ交谈

邮件:admin@example.com

工作时间:周一至周五,9:30-18:30,节假日休息

关注微信