Does yarn add package --build-from-source behave like npm install package --build-from-source when passing node-gyp flags to packages?

This is currently possible by using environment variables on the format npm_config_{snake_case_param}=true/false

For example, npm install --build-from-source=true becomes:

npm_config_build_from_source=true yarn install

It's documented here https://yarnpkg.com/lang/en/docs/envvars/#toc-npm-config


Yarn does not automatically expose -- arguments of install command to lifecycle scripts (pre/post/install scripts in package.json of dependencies). Here is the code where Yarn builds Env for the script execution https://github.com/yarnpkg/yarn/blob/master/src/util/execute-lifecycle-script.js#L39.

You can pass specific values via env setting in .yarnrc and also it builds npm_config_* settings based on .yarnrc/.npmrc configuration.