<#20592 Allow extra env vars during nodejs package...
# github-notifications
c
#20592 Allow extra env vars during nodejs package manager installation Issue created by kevinobruno Is your feature request related to a problem? Please describe. Pants doesn't allow passing extra env vars to the nodejs package manager during the installation of the packages, either through the
nodejs
subsystem or directly into the
package_json
target. When using
yarn
as the package manager, env vars can be very useful because almost all of the yarn settings can be set through env vars prefixed with
YARN_
, in replacement of having a
.yarnrc.yml
file. From yarn docs:
Copy code
Finally, note that most settings can also be defined through environment variables
(at least for the simpler ones; arrays and objects aren't supported yet).
To do this, just prefix the names and write them in snake case:
YARN_CACHE_FOLDER will set the cache folder (such values will overwrite any
that might have been defined in the RC files - use them sparingly).
https://v3.yarnpkg.com/configuration/yarnrc Describe the solution you'd like Allow passing extra env vars either through
nodejs
subsystem and/or the
package_json
target. On
pants.toml
file:
Copy code
[nodejs]
package_manager_extra_env_vars={"YARN_NODE_LINKER": "node-modules"}
and/or at the BUILD file:
Copy code
package_json(
    extra_env_vars={"YARN_NODE_LINKER": "node-modules"},
)
Describe alternatives you've considered Creating a
.yarnrc.yml
file and using the
files
target to have this file on sandbox during the
yarn install
works. It does however require some additional steps to set those yarn settings and also only addresses the yarn package manager.
Copy code
.yarnrc.yml

nodeLinker: node-modules
Copy code
BUILD

files(
    name="package_config",
    sources=[".yarnrc.yml"],
)

package_json(
    dependencies=[":package_config"],
)
pantsbuild/pants