'Override Platform for Yarn 2 install

I have a number of docker containers which have a volume shared with my local filesystem. I am trying to install the package esbuild, which has different versions for linux and darwin OS's. When I run yarn install locally, it installs the wrong package version, and ignores the correct version, no matter how I declare it, as it detects my darwin platform and assumes I don't need the linux version:

 esbuild-linux-64@npm:0.14.14 The linux-x64 architecture is incompatible with this module, link skipped.

I can connect to the container and run the install from there, and it installs the correct esbuild-linux-64 version in that case, but the install/build runs prohibitively slower because the container is much smaller than my machine.

I have looked through most of the Yarn documentation, and it seems they got rid of a couple of methods in Yarn Classic which allowed you to override the platform, or at least ignore incompatible package detection.

In Yarn v2, there is a new config setting, supportedArchitectures:, set in the .yarnrc.yml file, but it seems the yarn link step still ignores any incompatible packages which were included in supportedArchitectures.

Thanks for any help!



Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source