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

Remove one of package-lock.json and yarn.lock on gatsby new #13210

Closed
sidharthachatterjee opened this issue Apr 8, 2019 · 9 comments
Closed
Labels
help wanted Issue with a clear description that the community can help with.

Comments

@sidharthachatterjee
Copy link
Contributor

sidharthachatterjee commented Apr 8, 2019

Our starters currently include both package-lock.json and yarn.lock

This typically leads to some confusion due to yarn's warning (#4514 (comment))

package-lock.json found. Your project contains lock files generated by tools other than Yarn. It is advised not to mix package managers in order to avoid resolution inconsistencies caused by unsynchronized lock files. To clear this warning, remove package-lock.json.

And in worst case, inconsistencies between the two, leading to issues like #13194

Potential solution

It'd be nice to remove both lock files altogether but we can't because of #10607 (comment)

We could remove yarn.lock from the starter repositories and run yarn import if yarn is detected (this solves inconsistencies in the starter itself as well as inconsistencies after the project is created if both files are still present like in #13194)

What do you think @DSchau @KyleAMathews?

@sidharthachatterjee
Copy link
Contributor Author

@JacobBlomgren Want to take a stab at this?

@sidharthachatterjee
Copy link
Contributor Author

sidharthachatterjee commented Apr 8, 2019

Just remembered that we added @renovate[bot] and it'll handle updates to both package-lock.json and yarn.lock. And we only track package-lock.json in git, yarn.lock is created via yarn import in CI thanks to @DSchau

So all we really need to do is, during gatsby new

  • Check if yarn is installed
  • If it is, remove package-lock.json
  • If it is not, remove yarn.lock

The remove operations should not fail if the file doesn't exist (since starters from the community could contain one or two or none)

We could also prompt, but since we internally use yarn currently if it is available (https://github.com/gatsbyjs/gatsby/blob/master/packages/gatsby-cli/src/init-starter.js#L16-L28), we should just consistently do that for now

@sidharthachatterjee sidharthachatterjee added good first issue Issue that doesn't require previous experience with Gatsby help wanted Issue with a clear description that the community can help with. and removed good first issue Issue that doesn't require previous experience with Gatsby labels Apr 8, 2019
@pieh
Copy link
Contributor

pieh commented Apr 8, 2019

  • Check if yarn is installed
  • If it is, remove package-lock.json
  • If it is not, remove yarn.lock

Just to clarify: the check should be "if should use yarn" ( shouldUseYarn function that was linked by @sidharthachatterjee in previous comment) and not direct check if yarn is installed.

@KyleAMathews
Copy link
Contributor

The real long-term solution here is to ask people which client they use on their first gatsby new and then use that in the future.

@frinyvonnick
Copy link
Contributor

frinyvonnick commented Apr 8, 2019

Regarding of your discussion I made a first implementation that seems to solve this issue. I used prompts to ask user which package manager he wants to use then remove the unwanted lock file.

wardpeet pushed a commit that referenced this issue Apr 11, 2019
…tsby new (#13225)

## Description

I made a first implementation that asks user with [prompts](https://github.com/terkelg/prompts) which package manager he wants to use.

## Related Issues

Related to issue #13210
@frinyvonnick
Copy link
Contributor

Should I close this ?

@lannonbr
Copy link
Contributor

Yeah this has been resolved so I'll close it.

@idyWilliams
Copy link

'npm install' creates package-lock.json and 'yarn install' generates yarn.lock . Normally you stick to either one of the package managers in your project instead of having both..

@suhrob008
Copy link

image

what does it say

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
help wanted Issue with a clear description that the community can help with.
Projects
None yet
Development

No branches or pull requests

8 participants