TransformError:index.ios.js:找不到相对于目录的预置“ module:metro-react-native-babel-preset”

时间:2019-04-25 05:13:22

标签: ios swift xcode react-native babel

我有一个基于react native的应用程序,运行XCode时出现此错误

2019-04-24 21:49:42.688 [fatal][tid:main] TransformError: 
/Users/abearat/bb_projectspace/borroup/mobile_borroup/index.ios.js: 
Couldn't find preset "module:metro-react-native-babel-preset" 
relative to directory "/Users/abearat/bb_projectspace/borroup"

这是.babelrc文件

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

这是package.json文件

{
  "name": "BorroUp",
  "version": "1.0.0",
  "private": true,
  "scripts": {
    "start": "node node_modules/react-native/local-cli/cli.js start",
    "test": "jest"
},
  "dependencies": {
  "react": "16.0.0-alpha.6",
  "react-native": "0.44.0",
  "react-native-dates": "^2.0.4",
  "react-native-fbsdk": "^0.6.0",
  "react-native-router-flux": "^4.0.0-beta.28",
  "react-native-vector-icons": "4.1.1",
  "react-navigation": "1.0.0-beta.11",
  "react-redux": "5.0.4",
  "redux": "3.6.0",
  "redux-logger": "^3.0.6",
  "redux-persist": "4.8.0",
  "redux-thunk": "2.2.0",
  "tipsi-stripe": "^3.2.0"
},
  "devDependencies": {
  "@babel/core": "^7.4.3",
  "babel-core": "^7.0.0-bridge.0",
  "babel-jest": "^24.7.1",
  "babel-preset-react-native": "1.9.1",
  "jest": "20.0.1",
  "metro-react-native-babel-preset": "^0.53.1",
  "react-test-renderer": "16.0.0-alpha.6"
},
  "jest": {
  "preset": "react-native",
  "transform": {
    "^.+\\.js$": "<rootDir>/node_modules/react- 
  native/jest/preprocessor.js",
    "\\.(ts|tsx)$": "ts-jest"
               }
          }
}

我认为此错误正在发生,原因是目录指向错误的文件,我在此目录中有.babelrc文件

/Users/abearat/bb_projectspace/borroup/mobile_borroup/.babelrc

我不知道如何指向正确的目录?

我尝试过但不起作用的解决方案是:-

1)创建具有以下内容的babel.config.js(基本上等同于stock .babelrc)

2)将转换添加到package.json中的我的Jest配置中为我修复了

3)运行react-native-git-upgrade但出现此错误

zsh: command not found: react-native-git-upgrade

4)运行npm Start

0 个答案:

没有答案