安装 hermes-engine (0.71.2) 在React Native中卡住了。

15

我创建了一个新的React Native项目,然后安装了npm,运行了bundle install命令,然后cd iOS pod install,但它卡在了这里。

Installing React-perflogger (0.71.2)
Installing React-runtimeexecutor (0.71.2)
Installing ReactCommon (0.71.2)
Installing SocketRocket (0.6.0)
Installing TOCropViewController (2.6.1)
Installing Yoga (1.14.0)
Installing YogaKit (1.18.1)
Installing boost (1.76.0)
Installing fmt (6.2.1)
Installing glog (0.3.5)
Installing hermes-engine (0.71.2)

这是我的 package.json 文件

{
  "name": "ApproverApp",
  "version": "0.0.1",
  "private": true,
  "scripts": {
    "android": "react-native run-android",
    "ios": "react-native run-ios",
    "lint": "eslint .",
    "start": "react-native start",
    "test": "jest"
  },
  "dependencies": {
    "@react-native-async-storage/async-storage": "^1.16.1",
    "@react-navigation/bottom-tabs": "^6.2.0",
    "@react-navigation/drawer": "^6.5.5",
    "@react-navigation/native": "^6.0.8",
    "@react-navigation/native-stack": "^6.5.0",
    "@reduxjs/toolkit": "^1.8.0",
    "axios": "^0.26.1",
    "css-to-react-native": "^3.0.0",
    "lodash": "^4.17.21",
    "mime": "^3.0.0",
    "moment": "^2.29.1",
    "native-base": "^3.3.7",
    "react": "18.2.0",
    "react-native": "0.71.2",
    "react-native-calendars": "^1.1279.0",
    "react-native-date-picker": "^4.2.0",
    "react-native-dialog": "^9.2.1",
    "react-native-document-picker": "^8.0.0",
    "react-native-gesture-handler": "^2.3.0",
    "react-native-image-crop-picker": "^0.37.3",
    "react-native-modal": "^13.0.1",
    "react-native-permissions": "^3.3.1",
    "react-native-popup-menu": "^0.15.12",
    "react-native-reanimated": "^2.4.1",
    "react-native-responsive-fontsize": "^0.5.1",
    "react-native-responsive-screen": "^1.4.2",
    "react-native-safe-area-context": "^4.1.2",
    "react-native-screens": "^3.13.1",
    "react-native-size-matters": "^0.4.0",
    "react-native-svg": "^12.3.0",
    "react-native-svg-transformer": "^1.0.0",
    "react-native-swipe-list-view": "^3.2.9",
    "react-native-vector-icons": "^9.1.0",
    "react-redux": "^7.2.6",
    "redux": "^4.1.2",
    "redux-persist": "^6.0.0",
    "redux-thunk": "^2.4.1"
  },
  "devDependencies": {
    "@babel/core": "^7.20.0",
    "@babel/preset-env": "^7.20.0",
    "@babel/runtime": "^7.20.0",
    "@react-native-community/eslint-config": "^3.2.0",
    "@tsconfig/react-native": "^2.0.2",
    "@types/jest": "^29.2.1",
    "@types/react": "^18.0.24",
    "@types/react-test-renderer": "^18.0.0",
    "babel-jest": "^29.2.1",
    "eslint": "^8.19.0",
    "jest": "^29.2.1",
    "metro-react-native-babel-preset": "0.73.7",
    "prettier": "^2.4.1",
    "react-test-renderer": "18.2.0",
    "typescript": "4.8.4"
  },
  "jest": {
    "preset": "react-native"
  }
}
6个回答

25

实际上可能并没有卡住。 尝试 cd ios && pod install --verbose 以获取更多信息。 如下所示,它将在下载时显示时间消耗信息。 在我的情况下,它用了45分钟来下载和安装hermes-engine (0.71.4)。非常非常慢....

 % Total    % Received % Xferd  Average Speed   Time    Time     Time  Current
                                Dload  Upload   Total   Spent    Left  Speed

如果网络速度足够快,那么它就完成了。 - Engr.Aftab Ufaq

4
大部分时间问题是由于网络连接慢引起的。我在家里通过网络连接1创建一个新项目时,总是卡在那里,显示正在安装hermes-engine (0.71.2)。但是当我切换到办公室的另一个网络连接2后,使用命令npx react-native init mynewawesomeproject只需要5分钟就能创建一个新项目。正如@kyo-kurosagi在答案中提到的,你可以尝试这个方法来检查进度。下载和安装可能需要最多40分钟甚至更长时间。pod install --verbose

如果我们可以通过VPN更快地下载hermes-engine,那么我们如何将其作为本地缓存呢? - Soul Clinic
我之前连接的是2.5GHz的网络,后来切换到了5GHz的网络,速度变得非常快。 - undefined

2
如果您正在使用基于ARM芯片的设备,请尝试以下命令:arch -arm64 npx react-native init 项目名称

你能进一步解释一下吗? - Prashant Jangam

1

我通过遵循该评论中的说明解决了这个问题。

所以基本上你需要做以下几件事情:

  1. 安装Gemfile.ruby-version中列出的Ruby版本。你可以使用http://rbenv.org/或者https://rvm.io/安装和使用.ruby-version文件中的版本。这里提供了关于rbenv的说明。
  2. 使用bundle install安装正确的CocoaPods版本。
  3. 使用bundle exec pod repo update更新CocoaPods仓库。
  4. 进入ios文件夹,cd到该目录下,然后运行 bundle exec pod install来安装pods。

我遇到了以下错误:请求的URL返回错误:403。所以我认为我的问题与Ruby或Gem无关。¯_(ツ)_/¯ - Mike S.

0
你需要清理并重新安装你的pods:
1 - sudo gem install cocoapods-clean
2 - pod deintegrate 3 - pod clean(此选项已不再可用)
4 - sudo pod install --allow-root

0
在Mac M1上,使用arch -arm64 npx react-native init命令可以完美地运行。

将命令行调用放在反引号中有助于提高可读性,这样可以使内容看起来更像代码(固定宽度字符,不同的背景)。 - undefined
这实质上只是一个较差的复制品,复制自上面的答案:https://stackoverflow.com/a/75500604/7943564 - undefined

网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接