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

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

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.

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:

确定