Failed to run jetifier React Native

旧时模样 提交于 2019-12-19 03:18:43

问题


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:


Use this :

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

android.useAndroidX=true
android.enableJetifier=true

step 2: use these commands

First of all remove node_modules folder and reinstall it using

npm install 

or

yarn

and then

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

Call

npx jetify

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




回答2:


Use this:

react-native run-android --no-jetifier




回答3:


Just change from "C" directory to any other directory and then install/run starting from here "npm install -g react-native-cli" . Then create new project "react-native init AwesomeProject " use Yarn to install dependencies fast. It worked for me.




回答4:


The issue is in React Native CLI v2.6.1

Use Below steps to resolve the issue:

  • If you use lock files (yarn.lock or package-lock.json) - find the @react-native-community/cli entry, remove it, run yarn install / npm install once again.

  • If you don't use lock files – remove node_modules and run yarn install / npm install again.

  • Run yarn list @react-native-community/cli or npm list @react-native-community/cli and verify you're on the latest version (v2.6.2).

  • Run react-native run-android




回答5:


react-native run-android --no-jetifier

and again start server

react-native start




回答6:


I use this react-native run-android --no-jetifier worked me



来源:https://stackoverflow.com/questions/57048978/failed-to-run-jetifier-react-native

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!