Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How can I use template literals in an .env file?

I want to use JavaScript's Template Literals in an .env file.

Specifically, I am trying to store a JWT public key in the .env file:

PUBLIC_KEY=
`--BEGIN PUBLIC--
AAAAAA
BBBBBB
CCCCCC
--END PUBLIC--`

But when I try to pull it out using process.env.PUBLIC_KEY JS returns an empty string.

I am using gulp to translate TypeScript but the .env is in the root directory and is required at the start of the gulpfile.

like image 379
ebenezer Avatar asked Sep 02 '25 15:09

ebenezer


1 Answers

Good news. v16.0.0 and greater now supports JavaScript Template Literals.

You can use it like the following:

PUBLIC_KEY=`--BEGIN PUBLIC--
AAAAAA
BBBBBB
CCCCCC
--END PUBLIC--`
like image 64
mot Avatar answered Sep 05 '25 03:09

mot