javascript - 错误 : bundling failed: TypeError: Cannot read property 'bindings' of null

标签 javascript react-native babeljs

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

native react :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": { "preset": "react-native" } }

错误:

error: bundling failed: TypeError: Cannot read property 'bindings' of null at Scope.moveBindingTo (/home/manish/Desktop/Practice/donut/node_modules/@babel/traverse/lib/scope/index.js:867:13) at BlockScoping.updateScopeInfo (/home/manish/Desktop/Practice/donut/node_modules/babel-plugin-transform-es2015-block-scoping/lib/index.js:364:17) at BlockScoping.run (/home/manish/Desktop/Practice/donut/node_modules/babel-plugin-transform-es2015-block-scoping/lib/index.js:330:12) at PluginPass.BlockStatementSwitchStatementProgram (/home/manish/Desktop/Practice/donut/node_modules/babel-plugin-transform-es2015-block-scoping/lib/index.js:70:24) at newFn (/home/manish/Desktop/Practice/donut/node_modules/@babel/traverse/lib/visitors.js:193:21) at NodePath._call (/home/manish/Desktop/Practice/donut/node_modules/@babel/traverse/lib/path/context.js:53:20) at NodePath.call (/home/manish/Desktop/Practice/donut/node_modules/@babel/traverse/lib/path/context.js:40:17) at NodePath.visit (/home/manish/Desktop/Practice/donut/node_modules/@babel/traverse/lib/path/context.js:88:12) at 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), failed.

似乎错误是由于 babel 引起的。但无法获得解决方案。这个问题的解决方案是什么?

最佳答案

我在依赖项中使用 babel-preset-react-native,但现在已弃用 "metro-react-native-babel-preset": "^0.47.0"。所以,我在 .babelrc 文件中更新了它,并添加了以下行:

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

上面的代码解决了这个问题。

关于javascript - 错误 : bundling failed: TypeError: Cannot read property 'bindings' of null,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/52585399/

相关文章:

react-native - 任务 ':app:processDebugResources' 执行失败。 > 安卓资源链接失败可以再构建RN安卓版

Android 权限 RECEIVE_BOOT_COMPLETED vs firebase 远程推送通知 vs google play 策略

android - react-navigation v2 后退按钮关闭应用程序

node.js - Webpack模块沿着输出文件分布

react-native - 重复声明 "AnimatedComponent"可能是 react-native 的内部错误

javascript - 使用 Babel 创建单个 JavaScript 包的最佳方式

javascript - 当背景元素的 CSS 设置为光标 : pointer 时,iOS 仅检测 mouseleave

Javascript:在方法内部调用方法本身(使用原始参数)

javascript - 更改图像中的圆点

javascript - fontloader 和 textgeometry 在 threejs 中不起作用