我尝试运行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中添加这两行请 访问以获取完整指南
android.useAndroidX = true android.enableJetifier = true
步骤2:使用这些命令
首先删除node_modules文件夹,然后使用重新安装
npm install
要么
yarn
然后
npm install --save-dev jetifier npx jetify npx react-native run-android
呼叫
npx jetify
每次(您的依赖项更新或每次您安装node_modules时,都必须再次喷射)