Env file support

Version: 22.x

JSS applications and the JSS CLI support loading environment variables defined in .env files.

Node and NPM scripts defined in JSS applications load environment variables from .env files using the dotenv-flow package and respect the dotenv-flow overwriting priority.

The JSS CLI does not use the NODE_ENV variable and, therefore, only supports .env and .env.local files.

Variables inside of your .env* files are automatically expanded. This allows you to reference other values. If you attempt to use a $ in a variable value, it must be escaped with a backslash \. For example:

RequestResponse
PASSWORD=b

# becomes 'adminb'
EXPANDED=admin$PASSWORD

# becomes 'admin$PASSWORD'
ESCAPED=admin\$PASSWORD

Do you have some feedback for us?

If you have suggestions for improving this article,