英文:
iOS Bundling failed Unable to resolve module crypto React Native
问题
我目前正在开发一个React Native应用程序。每当我使用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
}
我已经尝试了几天来解决这个错误,但没有成功。有人可以帮助我吗?提前感谢。
英文:
I am currently working on an a React Native App. Whenever I start the App on the smartphone using the expo Go App I get the error:
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');
This is my package.json file
{
"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
}
I have been trying to solve the error for days but no success.
Could anyone help me out?
Thank you in advance.
答案1
得分: 0
我解决了这个问题。
而不是直接从数据库获取数据,我在Node中编写了一个API,单独运行它,然后通过服务器上的一个端点获取我需要的数据。
英文:
I solved the Problem.
Instead of fetching the data directly from the database, I wrote an API in Node, ran it separately, and then fetched what I required from the database through an endpoint in the server.
通过集体智慧和协作来改善编程学习和解决问题的方式。致力于成为全球开发者共同参与的知识库,让每个人都能够通过互相帮助和分享经验来进步。
评论