无法在无服务器框架中从自定义路径加载env文件
我无法使用无服务器框架加载位于自定义路径中的ENV文件。
ENV文件保存在项目中的文件夹“配置/环境”中,可用的文件为
- .env.prod
- prof
- .env.env.dev .env.qa
- serverless.yml
内容如下所示。
plugins:
- serverless-dotenv-plugin
custom:
stage: ${opt:stage, "dev"}
dotenv:
basePath: ./config/environment/
logging: false
的 ,我得到的错误如下
无法解析serverless.yml:变量分辨率错误:
- 无法在“ provider.xxxxxx”上解析变量:在“ env”来源找不到值,
- 无法在“ provider.xxxxxx”上解析变量:在“ env”来源找不到值,
- 无法在“ provider.xxxxxx”上解析变量:在“ env”来源找不到值,
- 无法在“ provider.xxxxxx”上解析变量:在“ env”来源找不到值,
- 无法在“ provider.xxxxxx”上解析变量:在“ env”来源找不到值,
似乎.env文件没有加载,任何帮助将不胜感激。
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.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
我有同样的问题。
当我从v2更新无服务器框架V3时,问题就会出现。
如果我不使用底部或路径并移动.env,.env.prod到root文件夹,则它可以正常工作,但我希望有更好的解决方案。
I have the same problem.
The problem happend when I update serverless framework v3 from v2.
If I don't use basePath or path and move .env, .env.prod to root folder it works, but I hope to have better solution.
在这里
Here