
Security News
ECMAScript 2025 Finalized with Iterator Helpers, Set Methods, RegExp.escape, and More
ECMAScript 2025 introduces Iterator Helpers, Set methods, JSON modules, and more in its latest spec update approved by Ecma in June 2025.
serverless-offline-dotenv
Advanced tools
Override environment variables when working locally with Serverless Offline.
Deprecation Notice
Serverless v3 introduces built-in support for dot-env files making this plugin somewhat redundant since:
- it's always best to use built-in functionality wherever possible
- the behavior of the two implementations are very much alike (though I've not thoroughly tested for any variations in behavior so could be wrong)
Please update your projects to use the native support for dot-env files instead, or raise an issue if you believe this plugin should continue to be maintained (with reasons why).
Override environment variables configured in serverless.yml
with any values provided in a .env
file located at the root of your project.
Both global and function-specific environment variables are overridden.
This plugin is intended for local development only, and is therefore only invoked on
serverless offline start
.
Install the plugin:
yarn add -D serverless-offline-dotenv
Add the plugin to your serverless.yml
file:
plugins:
- serverless-offline-dotenv
- serverless-offline
It is important that the serverless-offline-dotenv
plugin is loaded before serverless-offline
.
.env
fileCreate a file at the root of your project named .env
containing the environment variables that you
want to override locally.
# /path/to/project/.env
DB_HOSTNAME=127.0.0.1
DB_USER=me
# Lines starting with a hash are treated as comments
DB_PASSWORD=secret
Your .env
file may contain sensitive information so you should add it to your .gitignore
file.
You might want to provide a .env.example
template to make setup easier for other developers.
# /path/to/project/.env.example
DB_HOSTNAME=127.0.0.1
DB_USER=<your local database username here>
DB_PASSWORD=<your local database password here>
Developers can then create a .env
file from the template by running cp .env{.example,}
and make
the appropriate changes.
Any variables in your .env
file that are prefixed with SLS_
are assumed to be variables
supported by the Serverless framework
and are therefore always appended to all functions.
FAQs
Override environment variables when working locally with Serverless Offline.
The npm package serverless-offline-dotenv receives a total of 1,065 weekly downloads. As such, serverless-offline-dotenv popularity was classified as popular.
We found that serverless-offline-dotenv demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
ECMAScript 2025 introduces Iterator Helpers, Set methods, JSON modules, and more in its latest spec update approved by Ecma in June 2025.
Security News
A new Node.js homepage button linking to paid support for EOL versions has sparked a heated discussion among contributors and the wider community.
Research
North Korean threat actors linked to the Contagious Interview campaign return with 35 new malicious npm packages using a stealthy multi-stage malware loader.