Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Closed
AndreyTomilinXmpi opened this issue Jun 22, 2020 · 6 comments
Closed

Comments

@AndreyTomilinXmpi
Copy link

AndreyTomilinXmpi commented Jun 22, 2020

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'}
@edu-aguilar
Copy link

Im having the same problem.

@colynb
Copy link
Collaborator

colynb commented Jun 25, 2020

Thanks, I will look at this

@colynb
Copy link
Collaborator

colynb commented Jun 25, 2020

The env resolution checks for env in the following order. Can you check to see if these are not set to make sure they are not taking precedence?

process.env.NODE_ENV || options.env || options.stage || 'development'

@colynb
Copy link
Collaborator

colynb commented Jun 25, 2020

@AndreyTomilinXmpi
Copy link
Author

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!

@AndreyTomilinXmpi
Copy link
Author

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!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants