cli
cli copied to clipboard
npx react-native info and npx react-native init fails with error
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

Reproducible Demo
npx react-native info

same issue
I have the same issue: https://github.com/react-native-community/cli/issues/1681
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-gsv my command fails it doesn't even start the download
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
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 it doesn't work. I even removed expo and expo-cli.
@thymikee Can you please help here?
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 I tried but still no success. Also, no package.json there. not even react-native-cli or react-native-community/cli

@thymikee Any other information you would like me to provide?
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
I tried npx @react-native-community/cli init but still got same error.

npx create-react-app is working fine

@thymikee then issue seems to be in react native cli. Thanks for your time. Can you please tag someone who can help me.
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
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
Hi. New version of cli have been released, could you please give it a go?
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.
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
@adamTrz just tried this now, still same error.
@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)
@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 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
@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
@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
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.