Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: Error when creating a package. Error in step Copying template #383

Merged
merged 2 commits into from
May 9, 2023

Conversation

dvlkv
Copy link
Contributor

@dvlkv dvlkv commented Apr 26, 2023

Solves #382

Summary

Fixes #382 according to react-native issue

Test plan

#382 won't reproduce with yarn installed.

@atlj
Copy link
Collaborator

atlj commented Apr 30, 2023

Thanks for the PR!

Although forcing the CLI to use npm seems to fix the issue, we would still like to use yarn. I have gone through many issues and saw some people can see this issue while others are not. I've noticed newer versions of yarn such as 3.5.0 are causing this issue. I think until this issue is solved inside the CLI we can have this fix and remove it once it's fixed.

@satya164 WDTY?

@dvlkv
Copy link
Contributor Author

dvlkv commented Apr 30, 2023

Another solution is to add a flag which disables yarn. People who facing this issue can use this flag until it is not resolved inside the CLI.

@satya164
Copy link
Member

satya164 commented May 9, 2023

It's important to note that Yarn is required in the default template. There are scripts, CI etc. that uses Yarn. So adding a flag to disable Yarn for creating project doesn't help much when users will need to use it after creating the project anyway.

Maybe we should detect and throw an error if Yarn isn't installed.

@satya164
Copy link
Member

satya164 commented May 9, 2023

Though I also don't understand this - if it cannot be reproduced when Yarn is installed, what difference does --npm make? Isn't npm used regardless since Yarn isn't installed?

@atlj
Copy link
Collaborator

atlj commented May 9, 2023

@satya164 the problem happens when the user has a newer version of yarn like 3.5.0. The cli fails if that's the case. I've seen some discussion among cli folks to address this issue source.

Forcing cli to use npm if a newer version of yarn is installed might fix the issue. So maybe we can add a function to check the yarn version and if it's newer than a certain version, we can force cli init to use npm.

@satya164
Copy link
Member

satya164 commented May 9, 2023

@atlj gotcha. i was confused because the PR description says that it can't be reproduced when yarn is installed. i don't mind using --npm internally - but I'm against adding a flag to disabled yarn.

We can internally use an workaround but it probably makes more sense to fix it in CLI instead. But if it'll take too long or is too complicated, we can use --npm internally. We'll need to ensure the final project doesn't include any npm specific stuff like package-lock.json.

I wouldn't conditionally use Yarn or npm to generate the project since more branches means more surface for bugs. If we always use npm we can easily notice if anything breaks.

@atlj
Copy link
Collaborator

atlj commented May 9, 2023

@satya164 I've just checked the PR and no package-lock.json is generated since we pass the --skip-install flag to cli. I think it's good to merge but we should also watch this PR react-native-community/cli#1931 to remove this fix.

@atlj atlj self-requested a review May 9, 2023 10:39
atlj

This comment was marked as duplicate.

Copy link
Collaborator

@atlj atlj left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please address the linting issue

@atlj atlj merged commit 74a70bf into callstack:main May 9, 2023
@guillempuche
Copy link

Could you release the new version?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Error when creating a package. Error in step Copying template
4 participants