TypeError:无法读取null的属性“绑定”

时间:2019-05-06 12:39:49

标签: react-native webpack

我有一个具有本机@ 0.48.3响应的现成移动应用程序,并且在其中将要与webpack捆绑在一起的web应用程序,但是运行webpack时出现此错误,我认为这是版本问题,但我找不到哪个人导致了此错误:

   Module build failed (from ./node_modules/babel-loader/lib/index.js):
    TypeError: Cannot read property 'bindings' of null
    at Scope.moveBindingTo

这是我的package.json文件

   "dependencies": {
    "react": "16.0.0-alpha.12",
    "react-dom": "16.0.0-alpha.12",
    "react-native": "0.48.3",

    },
  "devDependencies": {
  "@babel/cli": "^7.0.0",
  "@babel/core": "^7.0.0",
  "@babel/plugin-transform-react-jsx-source": "^7.2.0",
  "@babel/preset-env": "^7.4.4",
  "@babel/preset-react": "^7.0.0",
  "babel-core": "^7.0.0-bridge.0",
   "babel-jest": "^21.0.2",
  "babel-loader": "^8.0.5",
  "babel-plugin-transform-es2015-block-scoping": "^6.26.0",
  "babel-preset-react-native": "5.0.1",
  "jest": "21.1.0",
  "metro-react-native-babel-preset": "^0.47.0",
  "react-test-renderer": "16.0.0-alpha.12",
  "regenerator-runtime": "^0.13.2",
  "url-loader": "^1.1.2",
  "webpack": "^4.28.4"
 },
 "jest": {
 "preset": "react-native"
  }

这是我的babel.config.js

 module.exports = {
    presets: ["module:metro-react-native-babel-preset","@babel/preset- 
    env"],
    plugins: ["@babel/plugin-proposal-object-rest-spread","@babel/plugin- 
    transform-react-jsx-source","transform-es2015-block-scoping"]
  };

1 个答案:

答案 0 :(得分:0)

更新您的package.json脚本,确保您使用的是 @babel/env ,而不是最新版本的--presets=env

"scripts": {
 "build": "babel ./src --out-dir ./build --presets=@babel/env",
}

这是重要的部分--presets=@babel/env