使用react-native-git-upgrade升级React原生项目后,我出现以下错误:

error: bundling failed: TypeError: Cannot read property 'bindings' of null
    at Scope.moveBindingTo (/Users/jan/Startup/react-native/ordersome/node_modules/@babel/traverse/lib/scope/index.js:978:13)
    at BlockScoping.updateScopeInfo (/Users/jan/Startup/react-native/ordersome/node_modules/babel-plugin-transform-es2015-block-scoping/lib/index.js:364:17)
    at BlockScoping.run (/Users/jan/Startup/react-native/ordersome/node_modules/babel-plugin-transform-es2015-block-scoping/lib/index.js:330:12)
    at PluginPass.BlockStatementSwitchStatementProgram (/Users/jan/Startup/react-native/ordersome/node_modules/babel-plugin-transform-es2015-block-scoping/lib/index.js:70:24)
    at newFn (/Users/jan/Startup/react-native/ordersome/node_modules/@babel/traverse/lib/visitors.js:237:21)
    at NodePath._call (/Users/jan/Startup/react-native/ordersome/node_modules/@babel/traverse/lib/path/context.js:65:20)
    at NodePath.call (/Users/jan/Startup/react-native/ordersome/node_modules/@babel/traverse/lib/path/context.js:40:17)
    at NodePath.visit (/Users/jan/Startup/react-native/ordersome/node_modules/@babel/traverse/lib/path/context.js:100:12)
    at TraversalContext.visitQueue (/Users/jan/Startup/react-native/ordersome/node_modules/@babel/traverse/lib/context.js:142:16)

这个问题似乎和巴贝尔有关.我重新启动了metro和模拟器,但这并没有改变任何事情.以下是我安装的所有与babel(package.json)有关的软件包:

"babel-eslint": "^8.2.5",
"babel-jest": "23.2.0",
"babel-preset-react-native": "4.0.0",

这是我的.babelrc:

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

我用react-native init生成了这个项目,当时它还是0.55.

推荐答案

try 更新包中babel-preset-react-native的版本.比如:

"babel-preset-react-native": "^5"

React-native相关问答推荐

在 React Native 中,水平滚动不适用于我的整个应用程序

Appcenter codepush 返回请求被阻止

什么是 expoClientId?

TypeError:未定义不是对象(判断'theme.spacing [radius]')

新的 react-native ios 应用程序没有构建?

应用程序主体尚未注册

找不到变量 atob

变量 window在react-native 中代表什么?

由于依赖关系,在 run-android 上构建失败

试图注册两个同名的视图 RNGestureHandlerButton

Jest 的配置在更新到 26.x 后抛出type ErrorHandler = (error: mixed, isFatal: boolean) => void

使用 applicationIdSuffix 时 React Native 应用程序不会启动

React Native 中的原生广告

react-native 元素/目录 struct 设置

在不使用 3rd 方库的情况下,在react-native中显示主屏幕之前显示启动画面

由于对 sourcetree 的 husky 预推送,Git 推送失败

在 React 中调用 getDerivedStateFromProps 中的方法

以编程方式读取 app.json(或 exp.json)

react-native图像预取

如何使用 Jest 测试导入自定义原生模块的 React Native 组件?