问题描述
我正在使用最新版本的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:
- 停止您的Expo应用程序服务器
- 删除您的
node_modules
目录和package-lock.json
- 运行
npm install
或yarn install
- 运行
npm install --save react-native-svg
- 通过运行
expo start -c
来启动您的应用程序
- Stop your Expo application server
- Delete your
node_modules
directory andpackage-lock.json
- Run
npm install
oryarn install
- Run
npm install --save react-native-svg
- Start your application by running
expo start -c
希望这会有所帮助!
这篇关于在React Native中导入图形工具包会导致错误500的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!