错误:绑定失败:TypeError:无法读取null的属性“绑定”

时间:2018-10-01 06:08:03

标签: javascript react-native babel

enter image description here在运行react-native应用程序时,我也面临着同样的问题。我使用的版本如下:

反应本机:0.57.1 react-native-cli:2.0.1 节点:v8.11.3 npm:5.6.0

Babel版本详细信息:

  

“ devDependencies”:{“ @ babel / runtime”:“ ^ 7.0.0”,“ babel-jest”:“ 20.0.3”,“ babel-preset-react-native”:“ ^ 2.1.0” ,“ jest”:“ 20.0.4”,“ react-test-renderer”:“ 16.0.0-alpha.12”,“ schedule”:“ ^ 0.4.0”},“ jest”:{“预设”: “ react-native”}}

错误:

  

错误:捆绑失败:TypeError:无法读取以下内容的属性“绑定”   空值       在Scope.moveBindingTo(/home/manish/Desktop/Practice/donut/node_modules/@babel/traverse/lib/scope/index.js:867:13)       在BlockScoping.updateScopeInfo(/home/manish/Desktop/Practice/donut/node_modules/babel-plugin-transform-es2015-block-scoping/lib/index.js:364:17)       在BlockScoping.run(/home/manish/Desktop/Practice/donut/node_modules/babel-plugin-transform-es2015-block-scoping/lib/index.js:330:12)       在PluginPass.BlockStatementSwitchStatementProgram(/home/manish/Desktop/Practice/donut/node_modules/babel-plugin-transform-es2015-block-scoping/lib/index.js:70:24)       在newFn(/home/manish/Desktop/Practice/donut/node_modules/@babel/traverse/lib/visitors.js:193:21)       在NodePath._call(/home/manish/Desktop/Practice/donut/node_modules/@babel/traverse/lib/path/context.js:53:20)       在NodePath.call(/home/manish/Desktop/Practice/donut/node_modules/@babel/traverse/lib/path/context.js:40:17)       在NodePath.visit(/home/manish/Desktop/Practice/donut/node_modules/@babel/traverse/lib/path/context.js:88:12)       在TraversalContext.visitQueue(/home/manish/Desktop/Practice/donut/node_modules/@babel/traverse/lib/context.js:118:16)   BUNDLE [android,dev] ./index.android.js░░░░░░░░░░░░░░░░0.0%   (0/3):: ffff:127.0.0.1--[01 / Oct / 2018:05:31:17 +0000]“ GET   /index.android.delta?platform=android&dev=true&minify=false HTTP / 1.1“   500-“-”“ okhttp / 3.10.0” Bundle [android,dev] ./index.android.js   ░░░░░░░░░░░░░░░░0.0%(0/3),失败。

似乎是由于通天塔而来的错误。但无法获得解决方案。该问题的解决方案是什么?

1 个答案:

答案 0 :(得分:4)

我在不依赖的情况下使用babel-preset-react-native,而不是“ metro-react-native-babel-preset”:现在正在使用“ ^ 0.47.0”。因此,我在.babelrc文件中对此进行了更新,并添加了以下行:

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

以上代码解决了该问题。