cli icon indicating copy to clipboard operation
cli copied to clipboard

npx react-native info and npx react-native init fails with error

Open rjatin007 opened this issue 3 years ago • 17 comments

Environment

Output of npx react-native info :- error Failed to load configuration of your project.

Description

npx react-native fails with error : - Failed to load configuration of your project. I have run this with --verbose too Screenshot 2022-08-18 at 7 46 45 PM

Reproducible Demo

npx react-native info Screenshot 2022-08-18 at 7 45 10 PM

rjatin007 avatar Aug 18 '22 14:08 rjatin007

same issue

nazrdogan avatar Aug 20 '22 15:08 nazrdogan

I have the same issue: https://github.com/react-native-community/cli/issues/1681

olivierlesnicki avatar Aug 25 '22 09:08 olivierlesnicki

I have the issue with npx react-native init, but the error is different, I deleted the .npm/_npx folder, and it works. You can refer to 1692 for more details to see if it can help.

xiaohui-hiwintech avatar Sep 02 '22 03:09 xiaohui-hiwintech

@xiaohui-gsv my command fails it doesn't even start the download

rjatin007 avatar Sep 02 '22 18:09 rjatin007

This is happening for me when trying to run npx react-native --verbose in a folder that is within another project that has a package.json (a monorepo). I noticed that I could init a new project in my Documents directory just fine, so then I went back to the monorepo folder (a folder up from where I originally tried & failed to init a new React Native project) and deleted the package-lock.json and package.json files. This time I was able to successfully npx react-native init

mjvestal avatar Sep 09 '22 21:09 mjvestal

i got this bug when i have expo-cli in my global list try : yarn global remove expo yarn global remove expo-cli npm uninstall -g expo npm uninstall -g expo-cli

and trying to clear node_modules , package.json , yarn.lock and other in path C/User/yourUserPath

piyawong avatar Sep 23 '22 07:09 piyawong

@piyawong it doesn't work. I even removed expo and expo-cli.

Screenshot 2022-09-24 at 12 13 34 AM

rjatin007 avatar Sep 23 '22 18:09 rjatin007

@thymikee Can you please help here?

rjatin007 avatar Sep 27 '22 18:09 rjatin007

Do you have a package.json somewhere in Desktop or "rn project" folder? If so, can you remove it? Have you tried running the command in a folder name without whitrspaces?

thymikee avatar Sep 27 '22 21:09 thymikee

@thymikee I tried but still no success. Also, no package.json there. not even react-native-cli or react-native-community/cli Screenshot 2022-09-28 at 1 26 52 PM Screenshot 2022-09-28 at 1 27 14 PM

rjatin007 avatar Sep 28 '22 07:09 rjatin007

@thymikee Any other information you would like me to provide?

rjatin007 avatar Sep 28 '22 17:09 rjatin007

Unfortunately I don't have the capacity to help you directly. Maybe there's some kind of antivirus preventing you from doing things? You can try npx @react-native-community/cli init and see if that works. Hope someone from the community can step in

thymikee avatar Sep 28 '22 18:09 thymikee

I tried npx @react-native-community/cli init but still got same error. Screenshot 2022-09-29 at 12 52 40 AM

rjatin007 avatar Sep 28 '22 19:09 rjatin007

npx create-react-app is working fine Screenshot 2022-09-29 at 12 57 42 AM

rjatin007 avatar Sep 28 '22 19:09 rjatin007

@thymikee then issue seems to be in react native cli. Thanks for your time. Can you please tag someone who can help me.

rjatin007 avatar Sep 28 '22 19:09 rjatin007

Another thing you could try to pin-point the issue is to install the @react-native-community/cli package as a dependency in a different directory, then modify the package's "index" file somewhat like this:

+     console.log(error);
      throw new CLIError(
        'Failed to load configuration of your project.',
        error,
      );
    }

Then call the path/to/cli/packages/cli/build/bin.js init and see if the error is logged. Then you should have a better understanding of what's going on. Also, I'd be interested in why the error didn't surface through the CLIError

thymikee avatar Sep 28 '22 21:09 thymikee

I still get the same error with [email protected] cli as a temp fix you can use an older cli it worked fine for me & you will still get the latest react-naive version 0.70.2 first clean up if you use yarn yarn global remove react-native-cli yarn global remove react-native if npm npm uninstall -g react-native-cli npm uninstall -g react-native then npx [email protected] init MyApp

zeejaydev avatar Oct 08 '22 18:10 zeejaydev

Hi. New version of cli have been released, could you please give it a go?

adamTrz avatar Oct 21 '22 11:10 adamTrz

If you search for "Failed to load configuration of your project." in node_modules, then modify it to:

throw new (_cliTools().CLIError)(`Failed to load configuration of your project. ${error.message}`, error);

it'll show the actual error. It'd be nice to make these changes here or here. Maybe it's configurable by environment, but for me CLIError is just swallowing the actual error.

bfischer1121 avatar Oct 27 '22 15:10 bfischer1121

Just seeing @thymikee gave the same tip above 😅 Anyway, for me it was a completely unrelated Nx issue (not dropping reference to an old dep), so I think this cli project is end up getting all the tickets since it's catching all the errors

bfischer1121 avatar Oct 27 '22 15:10 bfischer1121

@adamTrz just tried this now, still same error.

Screenshot 2022-11-01 at 1 27 08 AM

rjatin007 avatar Oct 31 '22 19:10 rjatin007

Screenshot 2022-11-01 at 1 56 36 AM

@thymikee I made directory rn_project then initialised it with npm inti -y. Next I installed the @react-native-community/cli package. And in same directory from VScode terminal I called this command that you wrote. Apparently error was int my IOS Setup but it did not surface on the CLI (refer screen shot attached)

rjatin007 avatar Oct 31 '22 20:10 rjatin007

@thymikee Thanks a lot for suggestion, but I think it would have been much easier for me as a developer if it would have surfaced on earlier.

@bfischer1121 Thanks and I agree there should be some displaye of error like this console statement in the index js file too.

Closing this issue with this comment.

rjatin007 avatar Oct 31 '22 20:10 rjatin007

@rjatin007 can you create a new feature request or even better a PR with the changes? Error should surface and we need to know why it didn't

thymikee avatar Nov 01 '22 07:11 thymikee

@rjatin007 can you create a new feature request or even better a PR with the changes? Error should surface and we need to know why it didn't

@thymikee Sure

rjatin007 avatar Nov 01 '22 07:11 rjatin007

Screenshot 2022-11-04 at 12 23 13 PM Screenshot 2022-11-04 at 12 18 45 PM

@thymikee Sorry for delay in sharing , but i found that even changing the ruby version to 2.7.5 , which was the issue that surfaced, even then the cli doesn't work if its not local one.

In above screenshots, first there is an empty folder named rn_project . I have logged ruby version which is 2.7.5. Next I tried to create project using npx react-native init abc and it should me the old error "faild to loead configuration of your project".

Next I initialised the rn_project with npm init -y and and installed react-native cli npm i --save @react-native-community/cli. then I tried with this cli and it worked.

Now how can I get to the error if local @react-native-community/cli is working but not npx.

Also npx react-native run-ios is giving error

Screenshot 2022-11-04 at 12 28 16 PM

rjatin007 avatar Nov 04 '22 06:11 rjatin007

There hasn't been any activity on this issue in the past 3 months, so it has been marked as stale and it will be closed automatically if no further activity occurs in the next 7 days.

github-actions[bot] avatar Feb 03 '23 03:02 github-actions[bot]