question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

[Feature] Support env variables in yarnrc

See original GitHub issue
  • I’d be willing to implement this feature
  • This feature can already be implemented through a plugin

Describe the user story

yarn v1 supports env variables in yarnrc/npmrc:

//registry.npmjs.org/:_authToken=${COMPANY_NPM_TOKEN}

but v2 doesn’t support it in .yarnrc.yml

Describe the solution you’d like

It would be nice to support env variables like in other tools/libraries (for example docker compose)

Issue Analytics

  • State:closed
  • Created 3 years ago
  • Reactions:6
  • Comments:5 (3 by maintainers)

github_iconTop GitHub Comments

7reactions
arcaniscommented, Jun 1, 2020
2reactions
DaneTheorycommented, Apr 12, 2020

You can inject runtime environment variables, including variables already defined within the active shell, by rerouting the yarnPath defined in .yarnrc.yml to a custom path containing a .js file which instantiates a valid Yarn v2 release in the form of a child_process. At that point, declaring custom process.env values is straight-forward. Though it does feel a bit hacky. Check out @yarkPkg Berry’s repo and you can see they do exactly that. However, I imagine best practices would be to utilize the pnpapi lifecycle as according to the docs.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Configuration options | Yarn - Package Manager
List of all the configuration option for Yarn (yarnrc files) ... Environment variables can be accessed from setting definitions by using the ${NAME}...
Read more >
Yarn envvars and .yarnrc files - w3resource
The environment variables defined in the process.env enable you to configure additional Yarn features. CHILD_CONCURRENCY. Process.env.
Read more >
Set yarn environment variables without using terminal directly
Almost all providers support custom environment variables. After you set up the variable, you can interpolate it in .yarnrc.yml (if you ...
Read more >
Migrating to Yarn 2 - Heroku Dev Center
This article is intended to help current Heroku users migrate from Yarn 1 to ... You will want to remove the environment variables...
Read more >
Using modern Yarn for deployment with Node.js on Azure App ...
.yarnrc.yml points to the Yarn version it will be using under .yarn/releases ... to node as NODE_ENV environment variable * debuggingEnabled ...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found