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

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

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:

  1. 嗨,我一直在进行一个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'
}

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

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)上

  1. 我已经在各处搜索,但找不到解决方案。请帮忙,谢谢!
  2. 以下是我的package.JSON文件:
  3. (接下来是您的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:

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

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

  1. BUNDLE ./index.js
  2. error: TypeError: Cannot read properties of undefined (reading 'transformFile')
  3. at C:\Users\hp\Downloads\masjid-app\masjid-app\node_modules\metro\src\Bundler.js:95:34
  4. at Generator.next (<anonymous>)
  5. at asyncGeneratorStep (C:\Users\hp\Downloads\masjid-app\masjid-app\node_modules\metro\src\Bundler.js:14:24)
  6. at _next (C:\Users\hp\Downloads\masjid-app\masjid-app\node_modules\metro\src\Bundler.js:36:9)
  7. 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

  1. {
  2. "name": "mockplus",
  3. "version": "0.0.1",
  4. "private": true,
  5. "scripts": {
  6. "android": "react-native run-android",
  7. "ios": "react-native run-ios",
  8. "start": "react-native start",
  9. "test": "jest",
  10. "lint": "eslint ."
  11. },
  12. "dependencies": {
  13. "@ant-design/icons": "^4.6.2",
  14. "@babel/preset-env": "^7.14.7",
  15. "@firebase/analytics": "^0.7.0",
  16. "@firebase/app": "^0.7.0",
  17. "@react-native-community/async-storage": "^1.12.1",
  18. "@react-native-community/cli-platform-android": "^5.0.1",
  19. "@react-native-community/geolocation": "^2.0.2",
  20. "@react-native-community/masked-view": "^0.1.11",
  21. "@react-native-community/push-notification-ios": "^1.10.1",
  22. "@react-native-community/slider": "^4.1.3",
  23. "@react-native-firebase/app": "^12.4.0",
  24. "@react-native-firebase/auth": "^12.4.0",
  25. "@react-native-firebase/messaging": "^12.4.0",
  26. "@react-native-picker/picker": "^2.0.0",
  27. "@react-navigation/bottom-tabs": "^5.11.11",
  28. "@react-navigation/drawer": "^5.12.5",
  29. "@react-navigation/native": "^5.9.4",
  30. "@react-navigation/stack": "^5.14.5",
  31. "axios": "^0.21.1",
  32. "brew": "^0.0.8",
  33. "gradle": "^1.2.4",
  34. "install": "^0.13.0",
  35. "lpf": "^1.0.0",
  36. "npm": "^7.21.0",
  37. "npm-install-peers": "^1.2.2",
  38. "react": "^16.14.0",
  39. "react-dom": "^17.0.2",
  40. "react-native": "0.64.4",
  41. "react-native-alarm-notification": "^1.8.0",
  42. "react-native-circle-checkbox": "^0.1.6",
  43. "react-native-compass-heading": "^1.2.1",
  44. "react-native-date-picker": "^4.2.10",
  45. "react-native-datepicker": "^1.7.2",
  46. "react-native-easy-grid": "^0.2.2",
  47. "react-native-element": "^1.2.1",
  48. "react-native-elements": "^3.4.2",
  49. "react-native-gesture-handler": "^1.10.3",
  50. "react-native-gifted-chat": "^0.16.3",
  51. "react-native-hijri-date-picker-android": "^2.0.0",
  52. "react-native-image-crop-picker": "^0.36.2",
  53. "react-native-image-placeholder": "^1.0.14",
  54. "react-native-looped-carousel": "^0.1.13",
  55. "react-native-modal": "^12.1.0",
  56. "react-native-onboarding-swiper": "^1.1.4",
  57. "react-native-picker-select": "^8.0.4",
  58. "react-native-progress": "^5.0.0",
  59. "react-native-push-notification": "^8.1.1",
  60. "react-native-read-more-text": "^1.1.2",
  61. "react-native-reanimated": "^2.2.0",
  62. "react-native-responsive-screen": "^1.4.2",
  63. "react-native-safe-area-context": "^3.2.0",
  64. "react-native-screens": "^3.4.0",
  65. "react-native-sensors": "^7.3.2",
  66. "react-native-share": "^7.0.0",
  67. "react-native-snackbar": "^2.4.0",
  68. "react-native-sound": "^0.11.0",
  69. "react-native-svg": "^12.1.1",
  70. "react-native-tab-view": "^3.1.1",
  71. "react-native-track-player": "^3.2.0",
  72. "react-native-tts": "^4.1.0",
  73. "react-native-vector-icons": "^8.1.0",
  74. "react-native-video": "^5.1.1",
  75. "react-native-youtube": "^2.0.2",
  76. "react-redux": "^7.2.4",
  77. "reanimated-bottom-sheet": "^1.0.0-alpha.22",
  78. "redux": "^4.1.0",
  79. "redux-thunk": "^2.3.0",
  80. "robust-point-in-polygon": "^1.0.3",
  81. "toggle-switch-react-native": "^3.2.0"
  82. },
  83. "devDependencies": {
  84. "@babel/core": "^7.12.9",
  85. "@babel/runtime": "^7.12.5",
  86. "@react-native-community/eslint-config": "^2.0.0",
  87. "babel-jest": "^26.6.3",
  88. "eslint": "7.14.0",
  89. "jest": "^26.6.3",
  90. "metro-react-native-babel-preset": "^0.64.0",
  91. "react-test-renderer": "17.0.1"
  92. },
  93. "jest": {
  94. "preset": "react-native"
  95. }
  96. }

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:

确定