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

Convert package-lock.json to yarn.lock #81

Closed
wants to merge 1 commit into from

Conversation

hsribei
Copy link

@hsribei hsribei commented Aug 31, 2018

When calling gatsby new, the command clones the repo and calls yarn on it.

Yarn creates its own lockfile and throws a warning on every subsequent run because there are both a yarn.lock and a package-lock.json.

This commit uses the synp npm package to fix that by converting package-lock.json to yarn.lock using these commands:

npm i
npx synp --source-file ./package-lock.json
yarn --update-checksums
git rm -f ./package-lock.json
git add yarn.lock

When calling `gatsby new`, the command clones the repo and calls `yarn`
on it.

Yarn creates its own lockfile and throws a warning on every subsequent
run because there are both a `yarn.lock` and a `package-lock.json`.

This commit uses the `synp` npm package to fix that by converting
`package-lock.json` to `yarn.lock` using these commands:

```
npm i
npx synp --source-file ./package-lock.json
yarn --update-checksums
git rm -f ./package-lock.json
git add yarn.lock
```
@KyleAMathews
Copy link
Contributor

We add a package-lock.json because gatsby new defaults to using yarn if it's installed but then sometimes people will install packages with npm. If there's not a package-lock.json then npm will delete all packages other than what it's installing which causes lots of issues.

There's a few ways we could fix this e.g. don't support yarn, ask people if they want to use yarn or npm when creating a site, etc.

Ideally we wouldn't ship a lock file at all.

@KyleAMathews
Copy link
Contributor

So yeah, the fix right now for the warning is to just remove the package-lock.json.

@hsribei
Copy link
Author

hsribei commented Aug 31, 2018

If there's not a package-lock.json then npm will delete all packages other than what it's installing which causes lots of issues.
😳

Ok didn't know that, thanks for the explanation. I should've seen 82b2681 and/or opened an issue before sending the PR. There is also an open issue about it here yarnpkg/yarn#5240.

Ideally we wouldn't ship a lock file at all.

Yeah I guess this situation will be easier once yarnpkg/yarn#5654 has some kind of resolution.

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.

2 participants