.env not read so ${ENV_VAR} unusable in .yarnrc.yml
See original GitHub issueDescribe the bug
I’m sure I must be doing something wrong, but I can’t get yarn to read the environment variables in my .env file, causing any yarn command to throw the following error when ${ENVIRONMENT_VARIABLES} are used in .yarnrc.yml:
Usage Error: Environment variable not found (ENVIRONMENT_VARIABLES) in [...]/.yarnrc.yml (in [...]/.yarnrc.yml)
Could it be that I have to configure something? The docs don’t seem to mention so.
To Reproduce
Clone this example repo and run yarn: https://github.com/lensbart/yarn
- macOS 11.2.3 (20D91)
- Node v14.16.0
- Yarn version 2.4.1
Note: I didn’t use Sherlock because I thought this might interfere with resolving the .env file
Issue Analytics
- State:
- Created 2 years ago
- Reactions:1
- Comments:9 (4 by maintainers)
Top Results From Across the Web
Set yarn environment variables without using terminal directly
I'm wondering if there's a way to tell yarn to do so by using package.json / .yarnrc.yml files. There's also preinstall hook where...
Read more >Docker ARG, ENV and .env - a Complete Guide - vsupalov.com
If you set an environment variable in an intermediate container using bash (RUN export ... They overlap, but ARG is not usable from...
Read more >Yarn envvars and .yarnrc files - w3resource
The tutorial you are about to read will examine environment variables, as well as the .yarnrc file.
Read more >Get a value from an environment variable - AWS Documentation
Sets bucket_name to undefined if environment variable not set var bucket_name = process.env.MYBUCKET; // Sets bucket_name to a default if env var doesn't...
Read more >Configuration options | Yarn - Package Manager
Starting from the v2, they must be written in valid Yaml and have the right extension (simply calling your file .yarnrc won't do)....
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Why not put them in your bashrc/zshrc/…?
I agree. Typical use case is for NPM auth tokens that may differ from a project to an other. It’d be great if Yarn could read the
.envfile before performing any logic, or at least let us opt in for that behaviour (e.g. by explicitly specifying a path to the file in question). Can try to work on a PR if it’s a setting that you’d consider integrating @arcanis.