iOS捆绑失败,无法解决模块crypto React Native。

huangapple go评论105阅读模式
英文:

iOS Bundling failed Unable to resolve module crypto React Native

问题

我目前正在开发一个React Native应用程序。每当我使用Expo Go应用程序在智能手机上启动应用程序时,我会收到以下错误:

  1. iOS Bundling failed 1795ms
  2. 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:
  3. node_modules
  4. > 1 | var Crypto = require('crypto');
  5. | ^
  6. 2 | var Events = require('events');
  7. 3 | var Net = require('net');
  8. 4 | var tls = require('tls');

这是我的package.json文件:

  1. {
  2. "name": "myapp",
  3. "version": "1.0.0",
  4. "main": "node_modules/expo/AppEntry.js",
  5. "scripts": {
  6. "start": "expo start",
  7. "android": "expo start --android",
  8. "ios": "expo start --ios",
  9. "web": "expo start --web"
  10. },
  11. "dependencies": {
  12. "@react-navigation/drawer": "^6.5.0",
  13. "@react-navigation/native": "^6.0.13",
  14. "@react-navigation/stack": "^6.3.2",
  15. "axios": "^1.4.0",
  16. "body-parser": "^1.20.2",
  17. "crypto-js": "^3.1.9-1",
  18. "events": "^3.3.0",
  19. "expo": "~46.0.16",
  20. "expo-crypto": "~11.0.0",
  21. "expo-status-bar": "~1.4.0",
  22. "express": "^4.18.2",
  23. "mysql": "^2.18.1",
  24. "node-fetch": "^2.6.11",
  25. "react": "18.0.0",
  26. "react-native": "0.69.6",
  27. "react-native-gesture-handler": "2.5.0",
  28. "react-native-reanimated": "~2.9.1",
  29. "react-native-safe-area-context": "4.3.1",
  30. "react-native-snap-carousel": "3.9.1",
  31. "url": "^0.11.1"
  32. },
  33. "devDependencies": {
  34. "@babel/core": "^7.12.9"
  35. },
  36. "private": true
  37. }

我已经尝试了几天来解决这个错误,但没有成功。有人可以帮助我吗?提前感谢。

英文:

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:

  1. iOS Bundling failed 1795ms
  2. 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:
  3. node_modules
  4. > 1 | var Crypto = require('crypto');
  5. | ^
  6. 2 | var Events = require('events');
  7. 3 | var Net = require('net');
  8. 4 | var tls = require('tls');

This is my package.json file

  1. {
  2. "name": "myapp",
  3. "version": "1.0.0",
  4. "main": "node_modules/expo/AppEntry.js",
  5. "scripts": {
  6. "start": "expo start",
  7. "android": "expo start --android",
  8. "ios": "expo start --ios",
  9. "web": "expo start --web"
  10. },
  11. "dependencies": {
  12. "@react-navigation/drawer": "^6.5.0",
  13. "@react-navigation/native": "^6.0.13",
  14. "@react-navigation/stack": "^6.3.2",
  15. "axios": "^1.4.0",
  16. "body-parser": "^1.20.2",
  17. "crypto-js": "^3.1.9-1",
  18. "events": "^3.3.0",
  19. "expo": "~46.0.16",
  20. "expo-crypto": "~11.0.0",
  21. "expo-status-bar": "~1.4.0",
  22. "express": "^4.18.2",
  23. "mysql": "^2.18.1",
  24. "node-fetch": "^2.6.11",
  25. "react": "18.0.0",
  26. "react-native": "0.69.6",
  27. "react-native-gesture-handler": "2.5.0",
  28. "react-native-reanimated": "~2.9.1",
  29. "react-native-safe-area-context": "4.3.1",
  30. "react-native-snap-carousel": "3.9.1",
  31. "url": "^0.11.1"
  32. },
  33. "devDependencies": {
  34. "@babel/core": "^7.12.9"
  35. },
  36. "private": true
  37. }

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.

huangapple
  • 本文由 发表于 2023年6月15日 19:25:29
  • 转载请务必保留本文链接:https://go.coder-hub.com/76481977.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定