The --stage parameter ignored when looking for the right .env file
See original GitHub issueI’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:
- Created 3 years ago
- Comments:6
Top 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 >
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
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!
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!