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.

The --stage parameter ignored when looking for the right .env file

See original GitHub issue

I’m running the serverless script with the next command line: client deploy –stage prod --region eu-west-1 --aws-profile MyProfile

As you see I’m specifying the –stage parameter, which according to this documentation should use the .env.prod file.

But I’m getting this message: Serverless: DOTENV: Could not find .env file.

All .env files are in sub-folder envs and here is my serverless config:

service: my-sevice-${opt:stage, self:provider.stage}

frameworkVersion: ">=1.1.0 <2.0.0"

plugins:
  - serverless-finch
  - serverless-dotenv-plugin

custom:
  dotenv:
    basePath: ./envs/
    include:
      - MY_VARIABLE

  ...

provider:
  name: aws
  runtime: nodejs12.x
  stage: ${opt:stage, 'develop'}

Issue Analytics

  • State:closed
  • Created 3 years ago
  • Comments:6

github_iconTop GitHub Comments

1reaction
AndreyTomilinXmpicommented, Jul 15, 2020

Finally I had time to recheck this issue. I have two different folders with serverless.yml. The above issue happens only in one of them. It looks like the problem relates to versions of some depended package(s). I was unable to determine which one (it’s not the serverless-dotenv-plugin itself). The only thing I can say for sure that if you perform clear installation - everything works as expected. I got my folders from other people, so not sure what other packages and in what order (may be it’s important?) they installed.

For now think you can close this issue.

Thanks for help!

0reactions
AndreyTomilinXmpicommented, Jun 25, 2020

Hi Colynb! Big thanks for your fast reply, Even with video. I tried to create small standalone sample, but was unable to reproduce this problem. Everything worked as expected. I will try to reproduce this issue on original project later, may be even next week. Don’t have time for that right now.

Maybe @edu-aguilar will provide his example.

Thanks again!

Read more comments on GitHub >

github_iconTop Results From Across the Web

Troubleshoot issues when passing environment variables to ...
Pass the variable as an environmentFiles object inside an Amazon Simple Storage Service (Amazon S3) bucket. Store the variable inside an AWS ...
Read more >
Symfony: .env.local and .env.test are ignored #99 - GitHub
local is always ignored in test env because tests should produce the same results for everyone. Secrets must go to .env.test.local file, right?...
Read more >
create react app not picking up .env files? - Stack Overflow
env variable loaded. I use ubuntu 16.4. try loading the varible from the terminal react-scripts start API_URL=http://localhost:3000/api ...
Read more >
Resolution of environment variables - Serverless Framework
The framework looks for .env and .env.{stage} files in service directory and then tries to load them using dotenv . If .env.{stage} is...
Read more >
Environment variables in Node.js. The Right way!
js execution environement i.e. NODE_ENV and exports the correct keys file. But how can I check Node.js environment before running our code? Look...
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