YARN_FLAGS env variable being ignored

My site name is https://homeclu-demo.netlify.app/

I have a problem where setting the “YARN_FLAGS” environment variable is not being used by the yarn install command as mentioned in the docs

I’ve tried setting it via the UI first, and via a netlify.toml file afterwards, of which neither worked.

I’m specifying the environment variable in netlify.toml as follows:

[build.environment]
    YARN_FLAGS = "--ignore-optional --registry https://npm.greensock.com"

The build log can be found here https://paste.ee/p/iHsMn

As you can see, Netlify is using yarn instead of npm correctly, as the repo does contain a yarn.lock file

Sorry to be slow to get back to you. hmm, interesting - is this problem still present? I am wondering if this might be a bug, but i’d need to get that confirmed.

This is still an issue yes.

Extract from logs of a build I just ran:

7:03:23 AM: Installing NPM modules using Yarn version 1.22.4
7:03:24 AM: yarn install v1.22.4

No flags being passed to yarn install

Thanks for confirming.

This error from your earlier-quoted seems pretty straightforward:

It means that your yarn registry is disallowing us access. What access methods are possible and what authentication have you configured to allow our build hosts access to your registry?

Right, the lack of access is something I’ve tried to fix by passing a --registry flag among other things.

I started this post because the YARN_FLAGS environment variable seems to be ignored, which should be apparent from the logs.
I’m not looking for support to fix the 403 error at the moment, I’m trying to understand why YARN_FLAGS is not working.

Hi, @Robin-Hoodie. There is a known bug where if there is more than one value in YARN_FLAGS (meaning, if there is a space in the value) then the environment variable isn’t parsed at all.

For example, this won’t work:

YARN_FLAGS = '--production=false --verbose'

However, either of these will:

YARN_FLAGS = '--production=false'
# or
YARN_FLAGS = '--verbose'

You might see if just the --registry option works (without --ignore-optional). However, it might be necessary to add an = so there is no space like so:

[build.environment]
    YARN_FLAGS = '--registry=https://npm.greensock.com/'

This might be enough to get the yarn install working.

About the bug, we will post an update here if the issue if known to be resolved.