gluestack-ui icon indicating copy to clipboard operation
gluestack-ui copied to clipboard

Error: Command failed: yarn config set legacy-peer-deps true

Open FezVrasta opened this issue 1 year ago • 28 comments

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

FezVrasta avatar Nov 06 '24 14:11 FezVrasta

would be useful if you added the actual output.

YDaskaloff avatar Nov 06 '24 14:11 YDaskaloff

It's in the title, Error: Command failed: yarn config set legacy-peer-deps true

FezVrasta avatar Nov 06 '24 14:11 FezVrasta

I just noticed the same happens when I try to add any component.

CleanShot 2024-11-06 at 4  25 45@2x

FezVrasta avatar Nov 06 '24 15:11 FezVrasta

+1

JavanPoirier avatar Nov 28 '24 08:11 JavanPoirier

+1

JMRMEDEV avatar Nov 29 '24 02:11 JMRMEDEV

+1

keepersmith avatar Dec 03 '24 15:12 keepersmith

"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?

keepersmith avatar Dec 03 '24 16:12 keepersmith

+1

Kwonkunkun avatar Dec 07 '24 08:12 Kwonkunkun

Thanks for reporting this. Currently, we provide full support for the Yarn Classic stable version (1.x) and will look into your suggestion.

rajat693 avatar Dec 09 '24 08:12 rajat693

Please help us.

myckhel avatar Dec 10 '24 20:12 myckhel

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

myckhel avatar Dec 10 '24 21:12 myckhel

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

bdotsamir avatar Jan 23 '25 04:01 bdotsamir

+1

b3ni avatar Jan 23 '25 17:01 b3ni

+1

okikiola-leaders avatar Jan 31 '25 16:01 okikiola-leaders

+1

andreiCrisan55 avatar Feb 10 '25 16:02 andreiCrisan55

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.

akash3gtm avatar Feb 14 '25 06:02 akash3gtm

Workaround ive been using is to run yarn install after the error.

myckhel avatar Feb 14 '25 08:02 myckhel

and there is no issue with anything when you don't use the --legacy-peer-deps?

akash3gtm avatar Feb 14 '25 09:02 akash3gtm

Yes sure.

myckhel avatar Feb 14 '25 11:02 myckhel

we will look into it, test and then update the cli.

thank you for reporting 😄

akash3gtm avatar Feb 14 '25 13:02 akash3gtm

+1

alparbartok avatar Feb 17 '25 18:02 alparbartok

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 .

akash3gtm avatar Feb 19 '25 06:02 akash3gtm

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

  1. 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.

  1. Deleted the yarn.lock file.

  2. 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!

kelmants avatar Mar 10 '25 16:03 kelmants

I can use gluestack-ui version 0.7.13 when add component.

  1. init gluestack-ui lastest version. yarn dlx gluestack-ui@latest init

  2. use version 0.7.13 to add component yarn dlx [email protected] add ...

It works for me. Hope It helps you.

thongdn-it avatar Apr 04 '25 07:04 thongdn-it

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.

MichaelrMentele avatar Apr 14 '25 16:04 MichaelrMentele

Is there any progress? we're delaying our migration to gluestack-ui v2 since we're using yarn v4

b00b00k avatar May 29 '25 04:05 b00b00k

also having the same issue @akash3gtm, but i've got a monorepo using workspaces, so the above workarounds don't work

rwitchell avatar Sep 04 '25 05:09 rwitchell

Something new on this issue? Same error in adding component

nlapointe-dev avatar Nov 03 '25 16:11 nlapointe-dev