Man*_*ish 9 javascript babel react-native
我在运行react-native应用程序时也遇到了同样的问题.我使用的版本如下:
React-Native:0.57.1 react-native-cli:2.0.1 node: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":{"预设":"反应 - 原生"}}
错误:
错误:捆绑失败:类型错误:在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(/家/马尼什/桌面/实践/甜甜圈/ node_modules /巴别-插件 - 转换 - ES2015 - 嵌段 - 作用域/ LIB/index.js:330:12)在PluginPass.BlockStatementSwitchStatementProgram(/家庭/和Manish /桌面/实践/甜甜圈/ node_modules/babel- newFn中的plugin-transform-es2015-block-scoping/lib/index.js:70:24)(/home/manish/Desktop/Practice/donut/node_modules/@babel/traverse/lib/visitors.js:193:21 )在NodePath.all上的NodePath._call(/home/manish/Desktop/Practice/donut/node_modules/@babel/traverse/lib/path/context.js:53:20)(/ home/manish/Desktop/Practice/donut/node_modules/@babel/traverse/lib/path/context.js:40:17)在NodePath.visit(/ home/manish/Desktop/Pr)actice/donut/node_modules/@babel/traverse/lib/path/context.js:88:12)在TraversalContext.visitQueue(/家/马尼什/桌面/业务/甜甜圈/ node_modules/@通天塔/横/ lib中/上下文. 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),失败了.
似乎错误是由于巴贝尔而来.但无法获得解决方案.这个问题的解决方案是什么?
我使用的babel-preset-react-native是已弃用的依赖项,而不是“ metro-react-native-babel-preset”:现在正在使用“ ^ 0.47.0”。因此,我在.babelrc文件中对此进行了更新,并添加了以下行:
{
"presets": ["module:metro-react-native-babel-preset"]
}
Run Code Online (Sandbox Code Playgroud)
上面的代码解决了该问题。