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

Use current yarn version on deploy to vercel #1007

Merged
merged 2 commits into from
Dec 7, 2024

Conversation

rin-st
Copy link
Member

@rin-st rin-st commented Dec 5, 2024

Description

Copying behaviors from #998

Current Behavior

deployment log from main branch

...
Running "vercel build"
Vercel CLI 39.1.1
Running "install" command: `yarn install`...
yarn install v1.22.19
info No lockfile found.
...

So our yarn.lock file is ignored and the last version will be installed when we have ^x.y.z versions of packages. It can cause errors

Expected Behavior

yarn version 3.2.3 should be used
yarn.lock should be used


Since our yarn.lock is located at the root of the repo, I think we can't use locked versions of nextjs package on our deploys. But it's possible at least to change yarn version to 3.2.3 from ^1. I'm still not sure if it adds a lot of value but I think it could solve some issues we had before when using yarn v1 or other incompatible yarn versions.

So, to use current version on deploy to vercel we need to add to package.json

  • packageManager
  • ENABLE_EXPERIMENTAL_COREPACK=1 to enable use of packageManager docs
  • YARN_ENABLE_IMMUTABLE_INSTALLS=false to enable creating new yarn.lock on deploy. I don't see it in the docs, but this helped to prevent this error:
Vercel CLI 39.1.3
> Detected ENABLE_EXPERIMENTAL_COREPACK=1 and "[email protected]" in package.json
Running "install" command: `yarn install`...
➤ YN0028: The lockfile would have been created by this install, which is explicitly forbidden.
➤ YN0000: Failed with errors in 0s 4ms
Error: Command "yarn install" exited with 1

Resulting build logs:

Running "vercel build"
Vercel CLI 39.1.3
> Detected ENABLE_EXPERIMENTAL_COREPACK=1 and "[email protected]" in package.json
Running "install" command: `yarn install`...
➤ YN0000: ┌ Resolution step
...

and it builds with no errors

Fixes #998

Additional Information

@rin-st rin-st requested a review from technophile-04 December 5, 2024 17:42
Copy link
Collaborator

@technophile-04 technophile-04 left a comment

Choose a reason for hiding this comment

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

Noiceee catch! And agree that it's more reliable to use yarn v3 with vercel clil deployment too!

I think it's fine we use "experimental" flag ENABLE_EXPERIMENTAL_COREPACK since maybe corepack is already being used a lot? and also if nodejs removes we would easily know the news remove that flag 🙌 Thanks @rin-st nice improvement!

@technophile-04 technophile-04 merged commit 3408257 into main Dec 7, 2024
1 check passed
@technophile-04 technophile-04 deleted the current-yarn-version-on-deploy branch December 7, 2024 03:17
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.

bug: yarn vercel uses yarn v1 and doesn't see yarn.lock
2 participants