.env not read so ${ENV_VAR} unusable in .yarnrc.yml

See original GitHub issue

Describe 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:closed
  • Created 2 years ago
  • Reactions:1
  • Comments:9 (4 by maintainers)

github_iconTop GitHub Comments

16reactions
arcaniscommented, Apr 9, 2021

Why not put them in your bashrc/zshrc/…?

12reactions
tavoynecommented, Jan 2, 2022

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 .env file 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.

Read more comments on GitHub >

github_iconTop 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 >

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