gluestack-ui
gluestack-ui copied to clipboard
Error: Command failed: yarn config set legacy-peer-deps true
Description
Trying to initialize a new project with gluestack-ui and Yarn 4.x errors out
CodeSandbox/Snack link
N/A
Steps to reproduce
yarn init
yarn set version 4.5.1
yarn dlx gluestack-ui@latest init
gluestack-ui Version
latest
Platform
- [X] Expo
- [ ] React Native CLI
- [ ] Next
- [ ] Web
- [ ] Android
- [ ] iOS
Other Platform
No response
Additional Information
No response
would be useful if you added the actual output.
It's in the title, Error: Command failed: yarn config set legacy-peer-deps true
I just noticed the same happens when I try to add any component.
+1
+1
+1
"npx gluestack-ui@latest init" just flat out does not work with yarn 2+ because of this. "classic" yarn is super old by now. Is this going to be fixed?
+1
Thanks for reporting this. Currently, we provide full support for the Yarn Classic stable version (1.x) and will look into your suggestion.
Please help us.
Please help us.
You're a software developer, use your problem solving skills... All I did was init a project with npm, and copy over all the components and deps. If you can't sort that out, you can pay the Gluestack team to help you. Them offering this fantastic library for free is help enough.
Off point man
Here's what I think is happening:
In modern versions of yarn, when you install a package, it installs its peer dependencies by default. This didn't always used to happen. It used to be that it wouldn't install peer deps by default. This is what setting this flag legacy-peer-deps does- it disables the automatic installation of peer dependencies. Here's where I'm getting this information from: https://stackoverflow.com/a/66620869/8916706
If somebody were to write up a quick PR, figuring out what the modern-day yarn equivalent is would be a great start
+1
+1
+1
We're waiting for yarn version latest version to be stable. Yarn's solution as mentioned in docs is to update the packages itself as to have better peer dependencies.
Since, we use other libraries like native-wind we can't actually do that.
Hence no solution at the moment.
If you guys have any suggestion in mind, we are always happy to get public contributions.
Workaround ive been using is to run yarn install after the error.
and there is no issue with anything when you don't use the --legacy-peer-deps?
Yes sure.
we will look into it, test and then update the cli.
thank you for reporting 😄
+1
This will take some time, we thank you for the patience.
for the time being you can use the hack to just run yarn again, and delete the .npmrc file where we do set the legacy-peer-deps=true .
Hi everyone,
@FezVrasta
Here's a workaround I managed to get working for me. I recently installed Glue for a new project and ran into an error. My setup is:
"react": "19.0.0",
"react-native": "0.78.0",
Using .yarn/releases/yarn-3.6.4.cjs
- Created a new file called .npmrc and added the following line: legacy-peer-deps=true
Yes, I know I'm using .yarnrc and .npmrc together, but it was necessary in this case.
-
Deleted the yarn.lock file.
-
Run the Glue initialisation command:
npx gluestack-ui init
After this, you'll be prompted to select a package manager:
No lockfile detected. Please select a package manager to install dependencies:
In my case, I selected yarn for my local project configuration.
Then, you'll be prompted again:
No lockfile detected. Please select a package manager to install dependencies:
This time, choosenpmso that it picks up the CLI configuration and doesn't conflict with legacy-peer-deps=true.
Then, wait for Glue to install.
Once it finishes the entire configuration, remove package-json.lock and run yarn install again.
I hope this workaround helps!
I can use gluestack-ui version 0.7.13 when add component.
-
init gluestack-ui lastest version.
yarn dlx gluestack-ui@latest init -
use version 0.7.13 to add component
yarn dlx [email protected] add ...
It works for me. Hope It helps you.
You can also follow the manual install instructions on a per components basis ie. for the accordion
yarn add @gluestack-ui/accordion @expo/html-elements and copy paste the component
https://gluestack.io/ui/docs/components/accordion
Not the best dx, but it works.
Is there any progress? we're delaying our migration to gluestack-ui v2 since we're using yarn v4
also having the same issue @akash3gtm, but i've got a monorepo using workspaces, so the above workarounds don't work
Something new on this issue? Same error in adding component