Open gfrileux opened 5 years ago
Hi,
the trouble is the plugin is assuming the environnent section is defined for the provider
at that line node_modules/serverless-env-generator/src/index.js:120:41
the undefined value is this.serverless.service.provider.environment
could it be a good idea to default everything to {} ?
ah ! I can confirm that my serverless.yml does not set this variable:
# serverless.yml
service: my-api
provider:
name: aws
runtime: nodejs8.10
stage: dev
region: eu-west-3
iamRoleStatements:
- Effect: Allow
Action:
- lambda:InvokeFunction
- lambda:InvokeAsync
Resource: '*'
plugins:
- serverless-domain-manager
- serverless-env-generator
- serverless-offline
# Plugin config goes into custom:
custom:
envFiles: #YAML files used to create .env file
- environment.yml
basePath: api
apiVersion: v1
...
rest of the file
May 2020, PR #10 is still not merged. For now my solution is to stick to exact version 1.3.0.
Please, can you comment here. Would you consider fixing this issue for serverless offline users ?
Hi,
I'm currently trying to use serverless-env-generator but must be doing something wrong, as I'm running into this error
Apparently, the culprit is here: this.options.environment = Object.assign(this.serverless.service.provider.environment, environment, dotenv.config({ path: path.join(config.servicePath, '.env.local') }).parsed)
and this.serverless.service.provider.environment is undefined...
Here my package.json:
I currently have a .env : USER_BACKEND_DOMAIN=http://
and my environment.yml : dev: USER_BACKEND_DOMAIN: 'http:///'
After intialising the project, I run
sls env --attribute USER_BACKEND_DOMAIN --value "http://<IP-address>/" --stage dev
Then:sls env create
Then I create my .env again (since it gets deleted by the "create" command
Finally, I run sls offline start
and get the error mentioned. I also tried sls offline start --stage dev but I get the same output.
Where am I going wrong ?
Thanks