`dotenv` looks in the wrong directory with `invoke local`
See original GitHub issueThis is an odd quirk in difference in how serverless offline
works vs serverless invoke local ...
today.
If using the dotenv
package, it will look for the .env
file in <root>/.env
in offline
. Alternatively, in invoke local
it will look for it in <root>/.esbuild/build/.env
instead.
The current working directory for the two methods appears to be different, I think this is caused by this PR: https://github.com/floydspace/serverless-esbuild/pull/122 but I am unsure…
Issue Analytics
- State:
- Created 2 years ago
- Comments:7
Top Results From Across the Web
dotenv file is not loading environment variables - Stack Overflow
Turns out I was running my app from my user/ directory with nodemon application_name/. and that was making dotenv look for the .env...
Read more >Error: ENOENT: no such file or directory, open '.env' · Issue #135
the solution is to use the terminal, run touch .env in your project root folder, a new .env file will be created and...
Read more >Dotenv - npm
Loads environment variables from .env file. Latest version: 16.0.3, last published: 3 months ago. Start using dotenv in your project by ...
Read more >Container environment variables - Visual Studio Code
As this example illustrates, containerEnv can reference local variables and ... Otherwise run Dev Containers: Open Folder in Container... to connect to the ......
Read more >python-dotenv - PyPI
By default, load_dotenv doesn't override existing environment variables. To configure the development environment, add a .env in the root directory of your ...
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 FreeTop 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
Top GitHub Comments
No, it’s only for the developer environment. It’s so you can have a local set of environment variables as a file, once deployed into production the env variables will be set specifically for that environment. So it’s not part of the package or deployment.
If you’re unfamiliar with dotenv, this might help a little bit on why it exists: https://github.com/motdotla/dotenv#faq
Yeah that’s a good point.
I think that might also be related to how
serverless offline
works. Sinceserverless invoke local
targets a single specific lambda but withserverless offline
we have no idea what lambda will be invoked and we rely on the behaviour of theserverless-offline
plugin to control the behaviour.So like you suggested that might just be a quirk between the two. Bare in mind both implementations do explicitly state that they are not a 100% perfect emulation but a good enough one.