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.

Try automatic resolution based on path and not load from the path

See original GitHub issue

So I have this monorepo setup where I want to have my .env.development and .env.production at the root level and reference the required variables in my service folders. Right now the path variable tries to load it directly from the file, without trying to find the file.

The issue with this approach is that if I hardcode what is my .env right now. I might have to change the path name in each service folder to production and then deploy. Which is cumbersome and feels wrong.

What I would like an option as readFrom and given a path and the whole thing will run on that path instead of the current repo.

What do you guys think around this? Anybody faced same issue? I Might want to put in a PR on this but need suggestions from collaborators, also is there anyway we can currently do this that I might be missing?

Issue Analytics

  • State:closed
  • Created 5 years ago
  • Reactions:1
  • Comments:12

github_iconTop GitHub Comments

1reaction
bryankennedycommented, Apr 8, 2019

I think I have a similar issue.

I run my serverless code inside of a subfolder of my larger project and the .env.${NODE_ENV} file is at the root. So in my server package I have this script:

NODE_ENV=development serverless deploy

Within my serverless.yml with the dotenv plugin I have:

custom:
  dotenv:
    path: ../../.env.${env:NODE_ENV}

But that doesn’t work. The system doesn’t load any of the env vars in that file.

If I hard code it like:

custom:
  dotenv:
    path: ../../.env.development

It works fine.

Is it possible to use environment variables in the setup of dotenv before it loads them from the file? I hope that makes a bit of sense. @SarasArya I hope this is the same as what you’re trying to accomplish.

0reactions
webchazcommented, May 7, 2019

@colynb Awesome, just tried it out, works great - thank you!

Read more comments on GitHub >

github_iconTop Results From Across the Web

Path mappings based module resolution · Issue #5039 - GitHub
Relative module names are computed treating location of source file that contains the import as base folder. Path mappings are not applied.
Read more >
Absolute module path resolution in TypeScript files in Visual ...
I've tried values like src , ./src and ./src/ , but none of them work in any of the upper configuration places. So...
Read more >
Documentation - Module Resolution - TypeScript
A non-relative import can be resolved relative to baseUrl , or through path mapping, which we'll cover below. They can also resolve to...
Read more >
Resolve-Path (Microsoft.PowerShell.Management)
The Resolve-Path cmdlet displays the items and containers that match the wildcard pattern at the location specified. The match can include files, folders, ......
Read more >
Module Resolution - webpack
Since we already have the absolute path to the file, no further resolution is required. Relative paths. import '../src/file1'; import ...
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