无法运行 jetifier React Native

2024-01-03

我尝试运行react-native run-android,但收到此错误。

info Running jetifier to migrate libraries to AndroidX. You can disable 
    it using "--no-jetifier" flag.
    error Failed to run jetifier. Run CLI with --verbose flag for more details.
    Error: spawnSync C:\Users\JayK\Desktop\React\AwesomeProject\node_modules\jetifier\bin\jetify ENOENT
    at Object.spawnSync (internal/child_process.js:1002:20)
    at spawnSync (child_process.js:614:24)
    at execFileSync (child_process.js:642:13)
    at Object.runAndroid [as func] (C:\Users\JayK\Desktop\React\AwesomeProject\node_modules\@react-native-community\cli-platform-android\build\commands\runAndroid\index.js:101:41)
    at Command.handleAction (C:\Users\JayK\Desktop\React\AwesomeProject\node_modules\@react-native-community\cli\build\cliEntry.js:160:21)
    at Command.listener (C:\Users\JayK\Desktop\React\AwesomeProject\node_modules\commander\index.js:315:8)
    at Command.emit (events.js:198:13)
    at Command.parseArgs (C:\Users\JayK\Desktop\React\AwesomeProject\node_modules\commander\index.js:651:12)
    at Command.parse (C:\Users\JayK\Desktop\React\AwesomeProject\node_modules\commander\index.js:474:21)
    at setupAndRun (C:\Users\JayK\Desktop\React\AwesomeProject\node_modules\@react-native-community\cli\build\cliEntry.js:210:24)


用这个 :

步骤1:在gradlew.properties中添加这两行访问获取完整指南 https://developer.android.com/jetpack/androidx/migrate

android.useAndroidX=true
android.enableJetifier=true

第 2 步:使用这些命令

首先删除node_modules文件夹并使用重新安装

npm install 

or

yarn

and then

npm install --save-dev jetifier 
npx jetify  
npx react-native run-android 

Call

npx jetify

每次(您的依赖项更新或每次安装node_modules时,您都必须再次jetify)

本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)

无法运行 jetifier React Native 的相关文章

随机推荐