首页 文章

react-native transform error找不到预设的“react-native”

提问于
浏览
2

在启动npm服务器后,在开发模式下运行react-native应用程序时 . 当应用程序请求捆绑包时,它会给出此错误,

enter image description here

The development server returned response error code:500

URL: http://192.168.1.55:8081/index.android.bundle?platform=android&
     dev=true&hot=false&minify=false

Body:
 {"message":"TransformError:/var/www/html/test_projects/test/index.android.js: 

Couldn't find preset \"react-native\" relative to directory
\"/var/www/html/test_projects\"","type":"TransofrmError","errors":[{}]}

2 回答

  • 0

    由于不兼容的反应和反应本机版本而发生此错误 . 要使其正常工作,您必须使用以下方法安装正确的react和react-native版本 .

    例如 .

    npm install --force react@15.2.0
    npm install --force react-native@0.28.0
    
  • 2

    检查你的package.json文件是否正确安装react-native . 您还可以使用以下内容在项目的根目录中创建 .babelrc 文件:

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

相关问题