无法运行 jetifier React Native [英] Failed to run jetifier React Native

查看:124
本文介绍了无法运行 jetifier React Native的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我尝试运行 react-native run-android,但出现此错误.

I tried to run react-native run-android and I got this error.

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 中添加这两行 访问完整指南

step 1: add these two lines in gradlew.properties Visit for complete guideline

android.useAndroidX=true
android.enableJetifier=true

android.useAndroidX=true
android.enableJetifier=true

第 2 步:使用这些命令

step 2: use these commands

首先删除 node_modules 文件夹并使用

First of all remove node_modules folder and reinstall it using

npm install 

yarn

然后

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

打电话

npx jetify

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

every time when (your dependencies update or every time you install node_modules you have to jetify again)

这篇关于无法运行 jetifier React Native的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆