build-image icon indicating copy to clipboard operation
build-image copied to clipboard

Fix support for Yarn 2 (berry)

Open ylemkimon opened this issue 5 years ago • 2 comments

  • Checks the version of Yarn installed globally using YARN_IGNORE_PATH=1. The environment variable YARN_VERSION sets the version of Yarn to install globally.
  • Sets YARN_GLOBAL_FOLDER environment variable to the cache directory. The cache-folder flag is deprecated in Yarn 2. The user can opt-in to use the global cache by setting YARN_ENABLE_GLOBAL_CACHE in Netlify settings. (See https://github.com/netlify/build-image/pull/465#discussion_r465539682)

Closes #319.

Suggestion for Docs: https://docs.netlify.com/configure-builds/environment-variables/#netlify-configuration-variables

- * `YARN_VERSION`: Sets the [Yarn version].
+ * `YARN_VERSION`: Sets the [Yarn version] to install globally.
+ * `YARN_ENABLE_GLOBAL_CACHE`: Use the [global cache](https://yarnpkg.com/configuration/yarnrc#enableGlobalCache) for Yarn 2. 

https://docs.netlify.com/configure-builds/manage-dependencies/#yarn

- * `YARN_VERSION`: defaults to the version preinstalled with your initial [build image]. Accepts any released version number.
+ * `YARN_VERSION`: defaults to the version preinstalled with your initial [build image]. Accepts any released version number. The specified version is installed globally.
+ * `YARN_ENABLE_GLOBAL_CACHE`: whether to use the [global cache](https://yarnpkg.com/configuration/yarnrc#enableGlobalCache) for Yarn 2. If you use zero-installs, do not set this variable.

CC @arcanis Could you check whether this is the right way to use Yarn 2 in CI?

ylemkimon avatar Aug 03 '20 11:08 ylemkimon

Would love for this to be merged in so that I move a site over to netlify. 🙏

benfurber avatar Apr 28 '21 20:04 benfurber

The line below export PATH=$(yarn bin):$PATH also needs to be updated; yarn bin on Yarn 2+ no longer returns a node_modules/.bin directory (which doesn't exist with PnP) but instead just lists all available binaries.

kevinji avatar Apr 07 '22 22:04 kevinji

Closing this PR as the it's against xenial branch and the Xenial image is going to be deprecated: https://answers.netlify.com/t/please-read-end-of-support-for-xenial-build-image-everything-you-need-to-know/68239

Feel free to reopen against focal branch.

kitop avatar Aug 24 '22 10:08 kitop