1、编译的时候语法莫名其妙的错误,一下是部分错误的贴图:
图 1 图 2 0该问题的原因是由于Babel没有进行配置导致的,是没有配置Babel导致的,所以只要配置好Babel就可以解决问题了,Babel配置如下:
package.json的配置 :
"devDependencies": {
"babel-jest": "23.4.2",
"babel-preset-react-native": "4.0.0",
"jest": "23.5.0",
"react-test-renderer": "16.3.1"
},
.babelrc 的配置如下:
{
"presets": ["env","react-native"],
"ignore": ["art/core/color.js"]
}
这样就可以解决问题了。
2、当项目升级到RN0.60之后,编译reactnative 报错 error: bundling failed cannot read property 'bindings' of null at scope.moveBindingTo () ,报错截图如下:
图 3解决方法:
package.json的配置 :
"devDependencies": {
"@babel/core": "^7.7.4",
"@babel/runtime": "^7.7.4",
"@react-native-community/eslint-config": "^0.0.5",
"eslint": "^6.7.1",
"babel-preset-env": "^1.7.0",
"babel-preset-react-native": "5.0.2",
"babel-jest": "^24.9.0",
"jest": "^24.9.0",
"react-test-renderer": "16.8.6",
"metro-react-native-babel-preset": "^0.57.0"
},
.babelrc 的配置如下:
{
"presets": ["module:metro-react-native-babel-preset"],
"ignore": ["art/core/color.js"]
}
OK , 记录问题解决过程。顺利跑通了。
网友评论