Native中导入图形工具包会导致错误500

Native中导入图形工具包会导致错误500

本文介绍了在React Native中导入图形工具包会导致错误500的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用最新版本的Expo.我已经由expo init my_project创建了一个项目,并添加了 React Native Chart Kit .这是package.json:

I am using the latest version of Expo. I have created a project by expo init my_project and added the React Native Chart Kit.Here is the package.json:

    {
  "main": "node_modules/expo/AppEntry.js",
  "scripts": {
    "start": "expo start",
    "android": "expo start --android",
    "ios": "expo start --ios",
    "web": "expo start --web",
    "eject": "expo eject"
  },
  "dependencies": {
    "expo": "^35.0.0",
    "react": "16.8.3",
    "react-dom": "16.8.3",
    "react-native": "https://github.com/expo/react-native/archive/sdk-35.0.0.tar.gz",
    "react-native-chart-kit": "^3.6.1",
    "react-native-web": "^0.11.7"
  },
  "devDependencies": {
    "babel-preset-expo": "^7.0.0"
  },
  "private": true
}

当我导入以下内容时,它给我错误:开发服务器返回了响应错误代码:500":

When I import the following it gives me the error: "The development server returned response error code: 500":

  import {
  LineChart,
  BarChart,
  PieChart,
  ProgressChart,
  ContributionGraph,
  StackedBarChart
} from "react-native-chart-kit";

即使按此[page] [2]所述通过Expo可以访问此模块,为什么仍会发生此错误?

Why this error happens even though this module is accessible through the Expo as it stated in this [page][2]?

[2]: https://forums.expo.io /t/any-graph-library/1674/7

推荐答案

在大多数情况下,此错误与您的node_modules有关,请尝试以下操作:

Most cases this error is related to your node_modules, try the following:

  1. 停止您的Expo应用程序服务器
  2. 删除您的node_modules目录和package-lock.json
  3. 运行npm installyarn install
  4. 运行npm install --save react-native-svg
  5. 通过运行expo start -c
  6. 来启动您的应用程序
  1. Stop your Expo application server
  2. Delete your node_modules directory and package-lock.json
  3. Run npm install or yarn install
  4. Run npm install --save react-native-svg
  5. Start your application by running expo start -c

希望这会有所帮助!

这篇关于在React Native中导入图形工具包会导致错误500的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

07-27 08:05