无法在命令“npx react-native run-android”上运行React Native项目。

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

Unable to run react-native project on command "npx react-native run-android"

问题

I understand that you want a translation of the code-related text you provided. Here's the translated version:

嗨,我一直在进行一个React Native项目的开发,一切都进展顺利,直到昨天我在项目完全执行之前使用命令```npx react-native run-android```时出现了错误,错误如下:

无法构建转换器:错误:error:0308010C:digital envelope routines::unsupported
在新的Hash (node:internal/crypto/hash:71:19)上
在Object.createHash (node:crypto:133:10)上
在stableHash (C:\Users\hp\Downloads\masjid-app\masjid-app\node_modules\metro-cache\src\stableHash.js:19:8)上
在Object.getCacheKey (C:\Users\hp\Downloads\masjid-app\masjid-app\node_modules\metro-transform-worker\src\index.js:647:7)上
在getTransformCacheKey (C:\Users\hp\Downloads\masjid-app\masjid-app\node_modules\metro\src\DeltaBundler\getTransformCacheKey.js:32:19)上
在新的Transformer (C:\Users\hp\Downloads\masjid-app\masjid-app\node_modules\metro\src\DeltaBundler\Transformer.js:180:28)上
在C:\Users\hp\Downloads\masjid-app\masjid-app\node_modules\metro\src\Bundler.js:58:29上
{
opensslErrorStack: [ 'error:03000086:digital envelope routines::initialization error' ],
library: 'digital envelope routines',
reason: 'unsupported',
code: 'ERR_OSSL_EVP_UNSUPPORTED'
}

当项目完全执行并安装到手机上后,会出现以下错误:

BUNDLE ./index.js

错误:TypeError:无法读取未定义的属性(读取'transformFile')
在C:\Users\hp\Downloads\masjid-app\masjid-app\node_modules\metro\src\Bundler.js:95:34上
在Generator.next ()上
在asyncGeneratorStep (C:\Users\hp\Downloads\masjid-app\masjid-app\node_modules\metro\src\Bundler.js:14:24)上
在_next (C:\Users\hp\Downloads\masjid-app\masjid-app\node_modules\metro\src\Bundler.js:36:9)上
在process.processTicksAndRejections (node:internal/process/task_queues:95:5)上

我已经在各处搜索,但找不到解决方案。请帮忙,谢谢!
以下是我的package.JSON文件:

(接下来是您的package.JSON文件的内容,未翻译)

如果您需要更多帮助,请告诉我。

英文:

Hi I am working on a react-native project for quite some time and everything was going well until yesterday I started to get an error on command npx react-native run-android in Metro before the project is yet to be completely executed and the error is:

Failed to construct transformer:  Error: error:0308010C:digital envelope routines::unsupported
    at new Hash (node:internal/crypto/hash:71:19)
    at Object.createHash (node:crypto:133:10)
    at stableHash (C:\Users\hp\Downloads\masjid-app\masjid-app\node_modules\metro-cache\src\stableHash.js:19:8)
    at Object.getCacheKey (C:\Users\hp\Downloads\masjid-app\masjid-app\node_modules\metro-transform-worker\src\index.js:647:7)
    at getTransformCacheKey (C:\Users\hp\Downloads\masjid-app\masjid-app\node_modules\metro\src\DeltaBundler\getTransformCacheKey.js:32:19)
    at new Transformer (C:\Users\hp\Downloads\masjid-app\masjid-app\node_modules\metro\src\DeltaBundler\Transformer.js:180:28)
    at C:\Users\hp\Downloads\masjid-app\masjid-app\node_modules\metro\src\Bundler.js:58:29 {
  opensslErrorStack: [ 'error:03000086:digital envelope routines::initialization error' ],
  library: 'digital envelope routines',
  reason: 'unsupported',
  code: 'ERR_OSSL_EVP_UNSUPPORTED'
}

And as the project gets 100 percent executed and gets installed in mobile it gives error as this

BUNDLE  ./index.js

error: TypeError: Cannot read properties of undefined (reading 'transformFile')
    at C:\Users\hp\Downloads\masjid-app\masjid-app\node_modules\metro\src\Bundler.js:95:34
    at Generator.next (<anonymous>)
    at asyncGeneratorStep (C:\Users\hp\Downloads\masjid-app\masjid-app\node_modules\metro\src\Bundler.js:14:24)
    at _next (C:\Users\hp\Downloads\masjid-app\masjid-app\node_modules\metro\src\Bundler.js:36:9)
    at process.processTicksAndRejections (node:internal/process/task_queues:95:5)

I searched it every where but cant find the solution any help, please!
Below is my package.JSON file

{
  "name": "mockplus",
  "version": "0.0.1",
  "private": true,
  "scripts": {
    "android": "react-native run-android",
    "ios": "react-native run-ios",
    "start": "react-native start",
    "test": "jest",
    "lint": "eslint ."
  },
  "dependencies": {
    "@ant-design/icons": "^4.6.2",
    "@babel/preset-env": "^7.14.7",
    "@firebase/analytics": "^0.7.0",
    "@firebase/app": "^0.7.0",
    "@react-native-community/async-storage": "^1.12.1",
    "@react-native-community/cli-platform-android": "^5.0.1",
    "@react-native-community/geolocation": "^2.0.2",
    "@react-native-community/masked-view": "^0.1.11",
    "@react-native-community/push-notification-ios": "^1.10.1",
    "@react-native-community/slider": "^4.1.3",
    "@react-native-firebase/app": "^12.4.0",
    "@react-native-firebase/auth": "^12.4.0",
    "@react-native-firebase/messaging": "^12.4.0",
    "@react-native-picker/picker": "^2.0.0",
    "@react-navigation/bottom-tabs": "^5.11.11",
    "@react-navigation/drawer": "^5.12.5",
    "@react-navigation/native": "^5.9.4",
    "@react-navigation/stack": "^5.14.5",
    "axios": "^0.21.1",
    "brew": "^0.0.8",
    "gradle": "^1.2.4",
    "install": "^0.13.0",
    "lpf": "^1.0.0",
    "npm": "^7.21.0",
    "npm-install-peers": "^1.2.2",
    "react": "^16.14.0",
    "react-dom": "^17.0.2",
    "react-native": "0.64.4",
    "react-native-alarm-notification": "^1.8.0",
    "react-native-circle-checkbox": "^0.1.6",
    "react-native-compass-heading": "^1.2.1",
    "react-native-date-picker": "^4.2.10",
    "react-native-datepicker": "^1.7.2",
    "react-native-easy-grid": "^0.2.2",
    "react-native-element": "^1.2.1",
    "react-native-elements": "^3.4.2",
    "react-native-gesture-handler": "^1.10.3",
    "react-native-gifted-chat": "^0.16.3",
    "react-native-hijri-date-picker-android": "^2.0.0",
    "react-native-image-crop-picker": "^0.36.2",
    "react-native-image-placeholder": "^1.0.14",
    "react-native-looped-carousel": "^0.1.13",
    "react-native-modal": "^12.1.0",
    "react-native-onboarding-swiper": "^1.1.4",
    "react-native-picker-select": "^8.0.4",
    "react-native-progress": "^5.0.0",
    "react-native-push-notification": "^8.1.1",
    "react-native-read-more-text": "^1.1.2",
    "react-native-reanimated": "^2.2.0",
    "react-native-responsive-screen": "^1.4.2",
    "react-native-safe-area-context": "^3.2.0",
    "react-native-screens": "^3.4.0",
    "react-native-sensors": "^7.3.2",
    "react-native-share": "^7.0.0",
    "react-native-snackbar": "^2.4.0",
    "react-native-sound": "^0.11.0",
    "react-native-svg": "^12.1.1",
    "react-native-tab-view": "^3.1.1",
    "react-native-track-player": "^3.2.0",
    "react-native-tts": "^4.1.0",
    "react-native-vector-icons": "^8.1.0",
    "react-native-video": "^5.1.1",
    "react-native-youtube": "^2.0.2",
    "react-redux": "^7.2.4",
    "reanimated-bottom-sheet": "^1.0.0-alpha.22",
    "redux": "^4.1.0",
    "redux-thunk": "^2.3.0",
    "robust-point-in-polygon": "^1.0.3",
    "toggle-switch-react-native": "^3.2.0"
  },
  "devDependencies": {
    "@babel/core": "^7.12.9",
    "@babel/runtime": "^7.12.5",
    "@react-native-community/eslint-config": "^2.0.0",
    "babel-jest": "^26.6.3",
    "eslint": "7.14.0",
    "jest": "^26.6.3",
    "metro-react-native-babel-preset": "^0.64.0",
    "react-test-renderer": "17.0.1"
  },
  "jest": {
    "preset": "react-native"
  }
}

If you do know the answer please help. Thank you.

答案1

得分: 1

我通过下面链接中发布的问题解决了我的问题:

https://stackoverflow.com/questions/70058295/react-native-error0308010cdigital-envelope-routinesunsupported

答案似乎很简单,我猜是因为我一直在使用的最新版 nodejs,版本为 18.16.0,所以参考上面链接中的问题,我使用 nvm 将我的 nodejs 版本更改为 16.13.0,一切都运行得很顺利。

英文:

so I solved my problem with the help of the question posted below at this link:

https://stackoverflow.com/questions/70058295/react-native-error0308010cdigital-envelope-routinesunsupported

The answer was quite simple I guess, there seems to be some problem with the latest version of nodejs that I have been using which was version 18.16.0 so by taking the reference from the above question in the link I changed my nodejs version to 16.13.0 using nvm and every thing worked like a charm.

huangapple
  • 本文由 发表于 2023年6月12日 20:57:05
  • 转载请务必保留本文链接:https://go.coder-hub.com/76456887.html
匿名

发表评论

匿名网友

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

确定