Unable to load env files from custom path in Serverless framework

Viewed 529

I am unable to load env files located in a custom path using serverless framework.

The env files are kept in a folder 'config/environment' in the project and the files available are

  • .env
  • .env.dev
  • .env.qa
  • .env.prod

The contents of Serverless.yml are as below

plugins:
   - serverless-dotenv-plugin
custom:
  stage: ${opt:stage, "dev"}
  dotenv:
    basePath: ./config/environment/
    logging: false

While triggering 'serverless deploy', I get error as below

Cannot resolve serverless.yml: Variables resolution errored with:

  • Cannot resolve variable at "provider.xxxxxx": Value not found at "env" source,
  • Cannot resolve variable at "provider.xxxxxx": Value not found at "env" source,
  • Cannot resolve variable at "provider.xxxxxx": Value not found at "env" source,
  • Cannot resolve variable at "provider.xxxxxx": Value not found at "env" source,
  • Cannot resolve variable at "provider.xxxxxx": Value not found at "env" source,

It seems the .env files are not getting loaded and any help will be appreciated.

0 Answers
Related