我正在开发一个React Native App。每当我使用expo Go应用程序在智能手机上启动应用程序时,我都会收到错误:
iOS Bundling failed 1795ms
Unable to resolve module crypto from /home/kaido/Documents/nonya/node_modules/mysql/lib/Connection.js: crypto could not be found within the project or in these directories:
node_modules
> 1 | var Crypto = require('crypto');
| ^
2 | var Events = require('events');
3 | var Net = require('net');
4 | var tls = require('tls');
这是我的package.json文件
{
"name": "myapp",
"version": "1.0.0",
"main": "node_modules/expo/AppEntry.js",
"scripts": {
"start": "expo start",
"android": "expo start --android",
"ios": "expo start --ios",
"web": "expo start --web"
},
"dependencies": {
"@react-navigation/drawer": "^6.5.0",
"@react-navigation/native": "^6.0.13",
"@react-navigation/stack": "^6.3.2",
"axios": "^1.4.0",
"body-parser": "^1.20.2",
"crypto-js": "^3.1.9-1",
"events": "^3.3.0",
"expo": "~46.0.16",
"expo-crypto": "~11.0.0",
"expo-status-bar": "~1.4.0",
"express": "^4.18.2",
"mysql": "^2.18.1",
"node-fetch": "^2.6.11",
"react": "18.0.0",
"react-native": "0.69.6",
"react-native-gesture-handler": "2.5.0",
"react-native-reanimated": "~2.9.1",
"react-native-safe-area-context": "4.3.1",
"react-native-snap-carousel": "3.9.1",
"url": "^0.11.1"
},
"devDependencies": {
"@babel/core": "^7.12.9"
},
"private": true
}
我已经试着解决这个错误好几天了,但没有成功。有人能帮我吗?先谢谢你。
1条答案
按热度按时间mec1mxoz1#
我解决了问题。我没有直接从数据库中获取数据,而是在Node中编写了一个API,单独运行它,然后通过服务器中的端点从数据库中获取所需的数据。